特区地址匹配管理
This commit is contained in:
parent
2309e96c99
commit
ed469d9877
BIN
public/static/tpl/import_speicalZone_info.xlsx
Normal file
BIN
public/static/tpl/import_speicalZone_info.xlsx
Normal file
Binary file not shown.
56
src/api/emis/emisSpecialZone.js
Normal file
56
src/api/emis/emisSpecialZone.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
//查询特区地址列表
|
||||||
|
export function listEmisSpecialZone(query) {
|
||||||
|
return request({
|
||||||
|
url: '/emis/emisSpecialZoneAddressMatch/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//查询特区地址详情
|
||||||
|
export function getEmisSpecialZone(id) {
|
||||||
|
return request({
|
||||||
|
url: '/emis/emisSpecialZoneAddressMatch/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//新增特区地址
|
||||||
|
export function addEmisSpecialZone(data) {
|
||||||
|
return request({
|
||||||
|
url: '/emis/emisSpecialZoneAddressMatch',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//删除特区地址
|
||||||
|
export function delEmisSpecialZone(ids) {
|
||||||
|
return request({
|
||||||
|
url: '/emis/emisSpecialZoneAddressMatch/' + ids,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//更新特区地址
|
||||||
|
export function updateEmisSpecialZone(data) {
|
||||||
|
return request({
|
||||||
|
url: '/emis/emisSpecialZoneAddressMatch',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
//批量导入特区地址
|
||||||
|
export function importEmisSpecialZone(data) {
|
||||||
|
return request({
|
||||||
|
url: '/emis/emisSpecialZoneAddressMatch/draftSubmit',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据地址匹配特区
|
||||||
|
export function matchByAddress(data) {
|
||||||
|
return request({
|
||||||
|
url: '/emis/emisSpecialZoneAddressMatch/matchByAddress?address=' + data.address,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
133
src/views/emis/emisSpecialZone/emisSpecialZoneForm.vue
Normal file
133
src/views/emis/emisSpecialZone/emisSpecialZoneForm.vue
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-row :gutter="0" style="display: flex;flex-wrap: wrap;">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="国家" prop="countryCode">
|
||||||
|
<CountryPicker v-model="form.countryCode" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="省份" prop="provinceCode">
|
||||||
|
<ProvincePicker :countryCode="form.countryCode" v-model="form.provinceCode" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="特区名称" prop="specialZoneName">
|
||||||
|
<el-input v-model="form.specialZoneName" type="text" placeholder="请输入特区名称" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="特区标签" prop="specialZoneTag">
|
||||||
|
<el-input v-model="form.specialZoneTag" type="text" placeholder="请输入特区标签" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" type="text" placeholder="请输入备注" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<div style="text-align: center;margin-bottom: 10px;">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import CountryPicker from '@/views/emis/EmisBaseTools/CountryPicker.vue';
|
||||||
|
import ProvincePicker from '@/views/emis/EmisBaseTools/ProvincePicker.vue';
|
||||||
|
import { addEmisSpecialZone, updateEmisSpecialZone,getEmisSpecialZone } from '@/api/emis/emisSpecialZone';
|
||||||
|
export default {
|
||||||
|
name: "EmisSpecialZoneForm",
|
||||||
|
components: {
|
||||||
|
CountryPicker,
|
||||||
|
ProvincePicker,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
id: {
|
||||||
|
type: Number,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: true,
|
||||||
|
form: {},
|
||||||
|
rules: {
|
||||||
|
countryCode: [{ required: true, message: '请选择国家', trigger: 'blur' }],
|
||||||
|
provinceCode: [{ required: true, message: '请选择省份', trigger: 'blur' }],
|
||||||
|
specialZoneName: [{ required: true, message: '请输入特区名称', trigger: 'blur' }],
|
||||||
|
specialZoneTag: [{ required: true, message: '请输入特区标签', trigger: 'blur' }],
|
||||||
|
},
|
||||||
|
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
id: {
|
||||||
|
handler(newVal, oldVal) {
|
||||||
|
this.initData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.initData();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
initData(){
|
||||||
|
if(this.id !=null) {
|
||||||
|
this.loading = true;
|
||||||
|
getEmisSpecialZone(this.id).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if(this.id !=null) {
|
||||||
|
updateEmisSpecialZone(this.form).then(response => {
|
||||||
|
if(response.code == 200) {
|
||||||
|
this.$message({
|
||||||
|
message: '修改成功',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
this.$emit("on-success");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
addEmisSpecialZone(this.form).then(response => {
|
||||||
|
if(response.code == 200) {
|
||||||
|
this.$message({
|
||||||
|
message: '新增成功',
|
||||||
|
type: 'success'
|
||||||
|
});
|
||||||
|
this.$emit("on-success");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
this.reset();
|
||||||
|
this.$emit("on-cancel");
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
countryCode: null,
|
||||||
|
provinceCode: null,
|
||||||
|
specialZoneName: null,
|
||||||
|
specialZoneTag: null,
|
||||||
|
remark: null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped></style>
|
||||||
354
src/views/emis/emisSpecialZone/index.vue
Normal file
354
src/views/emis/emisSpecialZone/index.vue
Normal file
@ -0,0 +1,354 @@
|
|||||||
|
<template>
|
||||||
|
<XdPageContainer class="app-container">
|
||||||
|
<SearchForm slot="pageHeader" :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">
|
||||||
|
</CountryPicker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('省份')" prop="provinceCode">
|
||||||
|
<ProvincePicker :placeholder="$t('省份')" :countryCode="queryParams.countryCode"
|
||||||
|
v-model="queryParams.provinceCode" ></ProvincePicker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item :label="$t('特区标签')" prop="specialZoneTag">
|
||||||
|
<el-input v-model="queryParams.specialZoneTag" placeholder="特区标签"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</SearchForm>
|
||||||
|
<xd-table slot="pageContent" slot-scope="slotProps" :height="(slotProps.contentHeight) + 'px'"
|
||||||
|
storageName="emisSpecialZoneList_main" v-loading="loading" border size="mini" :data="emisSpecialZoneList"
|
||||||
|
:showSearch.sync="showSearch" :total="total" @queryTable="getList" :queryParams="queryParams"
|
||||||
|
@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:emisSpecialZoneAddressMatch: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:emisSpecialZoneAddressMatch: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:emisSpecialZoneAddressMatch: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:emisSpecialZoneAddressMatch:export']">导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button plain class="filter-item" size="mini" type="primary" icon="el-icon-upload2"
|
||||||
|
@click="handleBatchImport"
|
||||||
|
v-hasPermi="['emis:emisSpecialZoneAddressMatch:draftSubmit']">批量导入</el-button>
|
||||||
|
<el-link type="primary" style="line-height: 28px;font-size:13px;color:blue"
|
||||||
|
href="/static/tpl/import_speicalZone_info.xlsx">下载导入Excel模板</el-link>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
<el-table-column type="selection" width="55" align="center" />
|
||||||
|
<el-table-column label="国家" align="left" prop="countryName" width="80" />
|
||||||
|
<el-table-column label="省份" align="left" prop="provinceName" width="150" />
|
||||||
|
<el-table-column label="特区名称" align="left" prop="specialZoneName" width="150" />
|
||||||
|
<el-table-column label="特区标签" align="left" prop="specialZoneTag" width="150" />
|
||||||
|
<el-table-column label="备注" align="left" prop="remark" width="150" />
|
||||||
|
<el-table-column label="创建人" align="left" prop="createByName" />
|
||||||
|
<el-table-column label="创建网点" align="left" prop="createSiteName" />
|
||||||
|
<el-table-column label="创建时间" align="left" prop="createTime" />
|
||||||
|
<el-table-column label="修改人" align="left" prop="updateByName" />
|
||||||
|
<el-table-column label="修改网点" align="left" prop="updateSiteName" />
|
||||||
|
<el-table-column label="修改时间" align="left" prop="updateTime" />
|
||||||
|
|
||||||
|
</xd-table>
|
||||||
|
<!-- 新增/修改表单 -->
|
||||||
|
<el-dialog :title="titleForm" :visible.sync="openForm" width="50%">
|
||||||
|
<EmisSpecialZoneForm ref="form" :id="currentId" @on-cancel="openForm = false" @on-changed="getList"
|
||||||
|
@on-success="handleSuccess">
|
||||||
|
</EmisSpecialZoneForm>
|
||||||
|
</el-dialog>
|
||||||
|
<!-- 批量导入弹窗 -->
|
||||||
|
<el-dialog title="上传文件" :visible.sync="openUploadForm" width="50%" v-dialogDrag :destroy-on-close="true"
|
||||||
|
:close-on-click-modal="false" append-to-body>
|
||||||
|
<el-row :gutter="0">
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" size="mini" label-width="80px">
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="选择文件" prop="uploadFile">
|
||||||
|
<el-upload action="" name="file"
|
||||||
|
accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
||||||
|
:show-file-list="true" :limit="1" :file-list="fileList" :tooltip="fileName"
|
||||||
|
:on-change="fileChange" :before-upload="beforeUpload">
|
||||||
|
<el-button slot="trigger" plain class="filter-item" size="mini"
|
||||||
|
type="primary">选择文件</el-button>
|
||||||
|
<el-link type="primary" style="line-height: 28px;font-size:13px;color:blue"
|
||||||
|
href="/static/tpl/batch_import_order.xls">下载导入Excel模板</el-link>
|
||||||
|
<div v-if="uploadExcelDataInfo != ''"
|
||||||
|
style="color: black;font-size: 12px;font-weight: 800;">{{ fileName }} {{
|
||||||
|
uploadExcelDataInfo }}</div>
|
||||||
|
</el-upload>
|
||||||
|
<el-alert title="注意" type="info" description="仅允许导入“xls”或“xlsx”格式文件!" close-text="知道了">
|
||||||
|
</el-alert>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="batchImpDataForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</XdPageContainer>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import CountryPicker from '@/views/emis/EmisBaseTools/CountryPicker.vue';
|
||||||
|
import ProvincePicker from '@/views/emis/EmisBaseTools/ProvincePicker.vue';
|
||||||
|
import EmisSpecialZoneForm from '@/views/emis/emisSpecialZone/emisSpecialZoneForm.vue';
|
||||||
|
import { listEmisSpecialZone, delEmisSpecialZone, importEmisSpecialZone } from '@/api/emis/emisSpecialZone';
|
||||||
|
import XLSX from 'xlsx'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'EmisSpecialZone',
|
||||||
|
components: {
|
||||||
|
CountryPicker,
|
||||||
|
ProvincePicker,
|
||||||
|
EmisSpecialZoneForm,
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
currentId: null,
|
||||||
|
titleForm: null,
|
||||||
|
openForm: false,
|
||||||
|
ids: [],
|
||||||
|
emisSpecialZoneList: [{
|
||||||
|
id: '1',
|
||||||
|
name: '测试'
|
||||||
|
}],
|
||||||
|
showSearch: true,
|
||||||
|
single: true,
|
||||||
|
multiple: true,
|
||||||
|
total: 0,
|
||||||
|
loading: false,
|
||||||
|
openUploadForm: false,
|
||||||
|
form: {},
|
||||||
|
rules: {
|
||||||
|
uploadFile: [{ required: true, message: '请选择文件', trigger: 'blur' }],
|
||||||
|
},
|
||||||
|
fileList: [],
|
||||||
|
fileName: '',
|
||||||
|
uploadExcelDataInfo: '',
|
||||||
|
queryParams: {
|
||||||
|
countryCode: null,
|
||||||
|
provinceCode: null,
|
||||||
|
specialZoneName: null,
|
||||||
|
specialZoneTag: null,
|
||||||
|
},
|
||||||
|
tmpDataList: [],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listEmisSpecialZone(this.queryParams).then(res => {
|
||||||
|
this.loading = false;
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.emisSpecialZoneList = res.rows;
|
||||||
|
this.total = res.total;
|
||||||
|
} else {
|
||||||
|
this.$message.error(res.msg || "获取特区列表失败");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
resetQuery() {
|
||||||
|
this.$refs.queryForm.resetFields();
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.id)
|
||||||
|
this.single = selection.length !== 1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
this.currentId = selection.length ? selection[0].id : null;
|
||||||
|
},
|
||||||
|
handleSortChange(column) {
|
||||||
|
this.queryParams.orderByColumn = column.prop;//查询字段是表格中字段名字
|
||||||
|
this.queryParams.isAsc = column.order;//动态取值排序顺序
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
handleAdd() {
|
||||||
|
this.currentId = null;
|
||||||
|
this.titleForm = "新增特区";
|
||||||
|
this.openForm = true;
|
||||||
|
},
|
||||||
|
handleUpdate() {
|
||||||
|
console.log('handleUpdate', this.currentId);
|
||||||
|
this.titleForm = "修改特区";
|
||||||
|
this.openForm = true;
|
||||||
|
},
|
||||||
|
handleDelete() {
|
||||||
|
const ids = this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除').then(function () {
|
||||||
|
return delEmisSpecialZone(ids);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => { });
|
||||||
|
},
|
||||||
|
handleExport() {
|
||||||
|
const loadingInstance = this.$loading({
|
||||||
|
text: '正在导出...'
|
||||||
|
})
|
||||||
|
var qParam = { ...this.queryParams };
|
||||||
|
qParam.pageNum = 1;
|
||||||
|
qParam.pageSize = 5000;
|
||||||
|
|
||||||
|
listEmisSpecialZone(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','prodCode','prodName','prodNameEn','status','country','transLineCode','transLine','carryType','transType','agingDesc','minAging','maxAging','remark','tenantId','delFlag','createBy','createTime','updateBy','updateTime',];
|
||||||
|
const tHeader = ['国家', '省份', '特区名称', '特区标签', '备注', '创建人', '创建网点', '创建时间', '修改人', '修改网点', '修改时间',];
|
||||||
|
const filterVal = ['countryCode', 'provinceCode', 'specialZoneName', 'specialZoneTag', 'remark', 'createBy', 'createTime', 'updateBy', 'updateTime',];
|
||||||
|
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]
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
handleBatchImport() {
|
||||||
|
this.openUploadForm = true;
|
||||||
|
},
|
||||||
|
batchImpDataForm() {
|
||||||
|
|
||||||
|
},
|
||||||
|
cancel() {
|
||||||
|
this.openUploadForm = false;
|
||||||
|
},
|
||||||
|
fileChange(file, fileList) {
|
||||||
|
this.fileList = fileList;
|
||||||
|
},
|
||||||
|
beforeUpload(file) {
|
||||||
|
this.fileName = file.name;
|
||||||
|
this.form.batchName = file.name;
|
||||||
|
this.readerData(file)
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
readerData(rawFile) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const reader = new FileReader()
|
||||||
|
reader.onload = e => {
|
||||||
|
const data = e.target.result
|
||||||
|
const workbook = XLSX.read(data, { type: 'array' })
|
||||||
|
const firstSheetName = workbook.SheetNames[0] // firstSheetName
|
||||||
|
const worksheet = workbook.Sheets[firstSheetName]
|
||||||
|
const results = XLSX.utils.sheet_to_json(worksheet)
|
||||||
|
this.batchImportData(results);
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
reader.readAsArrayBuffer(rawFile)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getHeaderRow(sheet) {
|
||||||
|
const headers = []
|
||||||
|
const range = XLSX.utils.decode_range(sheet['!ref'])
|
||||||
|
let C
|
||||||
|
const R = range.s.r
|
||||||
|
/* start in the first row */
|
||||||
|
for (C = range.s.c; C <= range.e.c; ++C) { /* walk every column in the range */
|
||||||
|
const cell = sheet[XLSX.utils.encode_cell({ c: C, r: R })]
|
||||||
|
/* find the cell in the first row */
|
||||||
|
let hdr = 'UNKNOWN ' + C // <-- replace with your desired default
|
||||||
|
if (cell && cell.t) hdr = XLSX.utils.format_cell(cell)
|
||||||
|
headers.push(hdr)
|
||||||
|
}
|
||||||
|
return headers
|
||||||
|
},
|
||||||
|
async batchImportData(results) {
|
||||||
|
const _index = 1
|
||||||
|
let loadingInstance = this.$loading({
|
||||||
|
text: '正在解析 ' + _index + ' 数据...'
|
||||||
|
})
|
||||||
|
this.tmpDataList = [];
|
||||||
|
// 组装提交的数据
|
||||||
|
for (let index = 0; index < results.length; index++) {
|
||||||
|
const element = results[index]
|
||||||
|
// 国家 省份 特区名称 特区标签 备注
|
||||||
|
let orderData = {
|
||||||
|
countryName: element['国家'],
|
||||||
|
provinceName: element['省份'],
|
||||||
|
specialZoneName: element['特区名称'],
|
||||||
|
specialZoneTag: element['特区标签'],
|
||||||
|
remark: element['备注'],
|
||||||
|
}
|
||||||
|
this.tmpDataList.push(orderData);
|
||||||
|
}
|
||||||
|
this.uploadExcelDataInfo = "总共 " + this.tmpDataList.length + " 条数据。";
|
||||||
|
loadingInstance.close()
|
||||||
|
},
|
||||||
|
|
||||||
|
async batchImpDataForm() {
|
||||||
|
// 判断是否有数据
|
||||||
|
if (this.tmpDataList.length == 0) {
|
||||||
|
this.$modal.msgError('表格中没有数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let len = this.tmpDataList.length;
|
||||||
|
for (let i = 0; i < len; i++) {
|
||||||
|
let itemData = this.tmpDataList[i];
|
||||||
|
try {
|
||||||
|
let res = await importEmisSpecialZone(itemData)
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.getList();
|
||||||
|
|
||||||
|
this.tmpDataList = [];
|
||||||
|
|
||||||
|
this.openUploadForm = false;
|
||||||
|
|
||||||
|
},
|
||||||
|
handleSuccess() {
|
||||||
|
this.openForm = false;
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped></style>
|
||||||
Loading…
Reference in New Issue
Block a user