完善转件管理页的导入功能
This commit is contained in:
parent
e2044cd860
commit
637254b8f6
@ -95,12 +95,13 @@
|
|||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<el-button
|
<!-- <el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
plain
|
plain
|
||||||
size="mini"
|
size="mini"
|
||||||
@click="handleImport"
|
@click="handleImport"
|
||||||
>导入</el-button>
|
>导入</el-button> -->
|
||||||
|
<el-button plain class="filter-item" size="mini" type="primary" icon="el-icon-upload2" @click="handleBatchImport">导入</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
<a href="/static/tpl/转件管理导出模板.xlsx" style="color: blue;font-weight: 600;font-size:13px;text-decoration: underline">下载导入模版</a>
|
<a href="/static/tpl/转件管理导出模板.xlsx" style="color: blue;font-weight: 600;font-size:13px;text-decoration: underline">下载导入模版</a>
|
||||||
@ -137,7 +138,7 @@
|
|||||||
<el-table-column :label="$t('电话')" align="center" prop="linkPhone" min-width="100" />
|
<el-table-column :label="$t('电话')" align="center" prop="linkPhone" min-width="100" />
|
||||||
<el-table-column :label="$t('签收状态')" align="center" prop="xxxx" min-width="100">
|
<el-table-column :label="$t('签收状态')" align="center" prop="xxxx" min-width="100">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-tag v-if="scope.row.waybillDetail.blSign=='1'" type="success">已签收</el-tag>
|
<el-tag v-if="scope.row.waybillDetail && scope.row.waybillDetail.blSign=='1'" type="success">已签收</el-tag>
|
||||||
<el-tag v-else type="danger">未签收</el-tag>
|
<el-tag v-else type="danger">未签收</el-tag>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -258,6 +259,41 @@
|
|||||||
<el-button @click="cancelForm">取 消</el-button>
|
<el-button @click="cancelForm">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</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/转件管理导出模板.xlsx">下载导入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>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@ -267,6 +303,7 @@ import EmisSiteSimplePicker from '@/views/emis/EmisBaseTools/EmisSiteSimplePicke
|
|||||||
import { getDateTimeToString } from '@/utils/payutils'
|
import { getDateTimeToString } from '@/utils/payutils'
|
||||||
import { parseTime, dateToStr } from "@/utils/custom";
|
import { parseTime, dateToStr } from "@/utils/custom";
|
||||||
import { getWaybillDetail } from "@/api/emis/emisWaybill";
|
import { getWaybillDetail } from "@/api/emis/emisWaybill";
|
||||||
|
import XLSX from 'xlsx'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "WaybillTransfer",
|
name: "WaybillTransfer",
|
||||||
@ -274,6 +311,12 @@ export default {
|
|||||||
dicts: ['emis_express_code'],
|
dicts: ['emis_express_code'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
resetRefreshId:null,
|
||||||
|
openUploadForm:false,
|
||||||
|
fileList:[],
|
||||||
|
uploadExcelDataInfo:"",
|
||||||
|
fileName:"",
|
||||||
|
tmpDataList: [],
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: false,
|
loading: false,
|
||||||
// 选中数组
|
// 选中数组
|
||||||
@ -438,7 +481,113 @@ export default {
|
|||||||
this.dateTimeRange=value;
|
this.dateTimeRange=value;
|
||||||
// scanDate
|
// scanDate
|
||||||
},
|
},
|
||||||
handleImport(){
|
getUUID() {
|
||||||
|
return Math.random().toString(36).substring(3,10);
|
||||||
|
},
|
||||||
|
handleBatchImport(){
|
||||||
|
this.resetRefreshId="importForm-"+this.getUUID();
|
||||||
|
this.openUploadForm=true;
|
||||||
|
this.fileList=[];
|
||||||
|
this.uploadExcelDataInfo="";
|
||||||
|
this.fileName="";
|
||||||
|
},
|
||||||
|
async batchImpDataForm() {
|
||||||
|
// 判断是否有数据
|
||||||
|
if(this.tmpDataList.length==0){
|
||||||
|
this.$modal.msgError('表格中没有数据');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// this.emisTransferList = this.emisTransferList.concat(this.tmpDataList);
|
||||||
|
for(let i = 0; i < this.tmpDataList.length; i++){
|
||||||
|
let response = await addEmisWaybillTransfer(this.tmpDataList[i]);
|
||||||
|
if(!response || response.code != 200 ){
|
||||||
|
this.$message.error(response && response.msg || "未知错误")
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.getList();
|
||||||
|
this.tmpDataList=[];
|
||||||
|
this.openUploadForm = false;
|
||||||
|
},
|
||||||
|
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) {
|
||||||
|
this.tmpDataList=[];
|
||||||
|
|
||||||
|
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
|
||||||
|
// if (!excelTypes.includes(firstSheetName)) {
|
||||||
|
// reject('无法识别当前Excel模板')
|
||||||
|
// this.$message.error('无法识别当前Excel模板')
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
const worksheet = workbook.Sheets[firstSheetName]
|
||||||
|
// const header = this.getHeaderRow(worksheet) // 标题
|
||||||
|
const results = XLSX.utils.sheet_to_json(worksheet, {raw: false})
|
||||||
|
|
||||||
|
console.log(results);
|
||||||
|
|
||||||
|
this.batchImportData(results);
|
||||||
|
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
reader.readAsArrayBuffer(rawFile)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async batchImportData(results) {
|
||||||
|
const _index = 1
|
||||||
|
let loadingInstance = this.$loading({
|
||||||
|
text: '正在解析 ' + _index + ' 数据...'
|
||||||
|
})
|
||||||
|
this.orderList = [];
|
||||||
|
// 组装提交的数据
|
||||||
|
for (let index = 0; index < results.length; index++) {
|
||||||
|
const element = results[index]
|
||||||
|
let orderData={
|
||||||
|
billCode: element['运单号'],
|
||||||
|
transferBillCode: element['转件单号'],
|
||||||
|
// transferDate2: element['转件时间'],
|
||||||
|
transferDate: parseTime(new Date(element['转件时间'])),
|
||||||
|
transferCity: element['目的城市'],
|
||||||
|
transferExpress: element['转件公司'],
|
||||||
|
linkMan:element['联系人'],
|
||||||
|
linkPhone:element['联系电话'],
|
||||||
|
transferWeight: element['重量'],
|
||||||
|
transferVolume: element['体积'],
|
||||||
|
transferFee: element['转件费'],
|
||||||
|
transferResean: element['转件原因'],
|
||||||
|
remark: element['备注'],
|
||||||
|
dataFrom: "pc",
|
||||||
|
createBy: this.$store.getters.empCode,
|
||||||
|
createByName: this.$store.getters.empName,
|
||||||
|
createTime: parseTime(new Date()),
|
||||||
|
createSite: this.$store.getters.ownerSiteCode,
|
||||||
|
createSiteName: this.$store.getters.ownerSiteName,
|
||||||
|
// blSign: "0",
|
||||||
|
|
||||||
|
uploadStatus: 0,
|
||||||
|
errorInfo:'',
|
||||||
|
}
|
||||||
|
debugger
|
||||||
|
this.tmpDataList.push(orderData);
|
||||||
|
|
||||||
|
}
|
||||||
|
this.uploadExcelDataInfo="总共 " + this.tmpDataList.length +" 条数据。";
|
||||||
|
loadingInstance.close()
|
||||||
|
|
||||||
},
|
},
|
||||||
submitForm(){
|
submitForm(){
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user