Merge branch 'master' of http://git.xdadan.loc/tanex/emis-frontend
This commit is contained in:
commit
f914164aee
BIN
public/static/tpl/imp_trans_quote_price.xlsx
Normal file
BIN
public/static/tpl/imp_trans_quote_price.xlsx
Normal file
Binary file not shown.
@ -52,3 +52,12 @@ export function batchUpdatePriceDate(data) {
|
||||
})
|
||||
}
|
||||
|
||||
//批量导入报价
|
||||
export function draftQuotePrice(data) {
|
||||
return request({
|
||||
url: '/emis/emisQuotePrice/draftQuotePrice',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
slot="pageContent"
|
||||
slot-scope="slotProps"
|
||||
:height="(slotProps.contentHeight)+'px'"
|
||||
|
||||
:row-class-name="tableRowClassName"
|
||||
v-loading="loading"
|
||||
border
|
||||
stripe
|
||||
@ -150,6 +150,17 @@
|
||||
v-hasPermi="['emis:emisQuotePrice:remove']"
|
||||
>删除</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">选择文件</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
size="mini"
|
||||
@click="handleBatchAdd"
|
||||
>批量新增</el-button>
|
||||
</el-col>
|
||||
<!-- <el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
@ -174,7 +185,21 @@
|
||||
<template slot-scope="scope">
|
||||
<div class="link-type" @click="handleUpdate(scope.row)">{{scope.row.quoteId}}</div>
|
||||
</template>
|
||||
</el-table-column> -->
|
||||
</el-table-column> -->
|
||||
<el-table-column :label="$t('状态')" align="center" prop="uploadStatus" min-width="80" :show-overflow-tooltip="true" >
|
||||
<template slot-scope="scope">
|
||||
<el-tag v-if="scope.row.uploadStatus==1" type="success">新增成功</el-tag>
|
||||
<el-tag v-if="scope.row.uploadStatus==0" type="info">待新增</el-tag>
|
||||
<el-tag v-if="scope.row.uploadStatus==-1" type="danger">新增异常</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('异常信息')" align="center" prop="errorInfo" min-width="300" :show-overflow-tooltip="true" >
|
||||
<template slot-scope="scope">
|
||||
<span v-if="scope.row.uploadStatus==-1" style="color:red">{{ scope.row.errorInfo }}</span>
|
||||
<span v-if="scope.row.uploadStatus==1">新增成功</span>
|
||||
<span v-if="scope.row.uploadStatus==0">待新增</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="报价名称" align="left" prop="quoteName" :show-overflow-tooltip="true" width="350" >
|
||||
<template slot-scope="scope">
|
||||
<div class="link-type" @click="handleUpdate(scope.row)">
|
||||
@ -258,13 +283,49 @@
|
||||
<BatchQuotePriceUpdateForm :ids="ids" @on-changed="handleBatchFormChanged" @on-cancel="cancelBatchForm"></BatchQuotePriceUpdateForm>
|
||||
</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/imp_trans_quote_price.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>
|
||||
</XdPageContainer>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
import { listEmisQuotePrice, getEmisQuotePrice, delEmisQuotePrice, addEmisQuotePrice, updateEmisQuotePrice } from "@/api/emis/emisQuotePrice";
|
||||
import { listEmisQuotePrice, getEmisQuotePrice, delEmisQuotePrice, addEmisQuotePrice, updateEmisQuotePrice, draftQuotePrice } from "@/api/emis/emisQuotePrice";
|
||||
import elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
|
||||
import emisQuotePriceForm from '@/views/emis/emisQuotePrice/emisQuotePriceForm';
|
||||
|
||||
@ -277,8 +338,7 @@ import TransLinePicker from '@/views/emis/EmisBaseTools/TransLinePicker.vue';
|
||||
import TransProductPicker from '@/views/emis/EmisBaseTools/TransProductPicker.vue';
|
||||
|
||||
import BatchQuotePriceUpdateForm from '@/views/emis/emisQuotePrice/batchQuotePriceUpdateForm.vue';
|
||||
|
||||
|
||||
import XLSX from 'xlsx'
|
||||
export default {
|
||||
name: "TransQuotePriceList",
|
||||
components: { elDateSimplePicker,emisQuotePriceForm,CountryPicker,
|
||||
@ -319,16 +379,26 @@ export default {
|
||||
|
||||
openBatchUpdateForm:false,
|
||||
titleBatchForm: "",
|
||||
|
||||
form:{},
|
||||
rules:{},
|
||||
openForm: false,
|
||||
titleForm: "",
|
||||
isCopy: false,
|
||||
|
||||
fileName:"",
|
||||
fileList:[],
|
||||
// 显示编辑框更多
|
||||
moreInputVisible: false,
|
||||
// 弹出展示层
|
||||
titleView:"",
|
||||
openView: false,
|
||||
//批量录入弹出
|
||||
openUploadForm:false,
|
||||
uploadMsg:"",
|
||||
uploadExcelDataInfo:"",
|
||||
//导入模板列表表格数据
|
||||
tmpDataList: [],
|
||||
selectionList:[],
|
||||
selectionIndexList: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@ -418,6 +488,7 @@ export default {
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.selectionList = selection;
|
||||
this.ids = selection.map(item => item.quoteId)
|
||||
let [lastObj]=selection.slice(-1);
|
||||
this.currentQuote=lastObj;
|
||||
@ -484,13 +555,28 @@ export default {
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const quoteIds = row.quoteId || this.ids;
|
||||
this.$modal.confirm('是否确认删除').then(function() {
|
||||
return delEmisQuotePrice(quoteIds);
|
||||
const quoteIds = row.quoteId || this.ids.filter(Boolean);
|
||||
let that = this;
|
||||
this.$modal.confirm('是否确认删除').then(function () {
|
||||
|
||||
if (quoteIds.length == 0) { //已上传
|
||||
that.selectionList.forEach((item, index) => {
|
||||
that.emisQuotePriceList.forEach((v, i) => {
|
||||
if (item.index === v.index) {
|
||||
that.emisQuotePriceList.splice(i, 1)
|
||||
}
|
||||
})
|
||||
})
|
||||
that.total = that.emisQuotePriceList.length;
|
||||
} else { //已新增
|
||||
delEmisQuotePrice(quoteIds).then(() => {
|
||||
that.getList();
|
||||
})
|
||||
}
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
that.$refs.multipleTable.clearSelection();
|
||||
}).catch(() => { });
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
@ -547,7 +633,162 @@ export default {
|
||||
dateTimeChange(value){
|
||||
this.dateTimeRange=value;
|
||||
},
|
||||
}
|
||||
handleBatchImport(){
|
||||
this.resetRefreshId="importForm-"+this.getUUID();
|
||||
|
||||
this.openUploadForm=true;
|
||||
this.fileList=[];
|
||||
this.uploadExcelDataInfo="";
|
||||
this.fileName="";
|
||||
},
|
||||
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)
|
||||
})
|
||||
},
|
||||
async batchImportData(results) {
|
||||
const _index = 1
|
||||
let loadingInstance = this.$loading({
|
||||
text: '正在解析 ' + _index + ' 数据...'
|
||||
})
|
||||
this.emisQuotePriceList =[];
|
||||
// 组装提交的数据
|
||||
for (let index = 0; index < results.length; index++) {
|
||||
const element = results[index]
|
||||
let orderData={
|
||||
quoteName: element['报价名称'],
|
||||
useSiteName: element['使用网点'], //需要后面转成code
|
||||
transLine: element['线路'], //转code
|
||||
prodName:element['产品类型'], //转code
|
||||
leastPrice:element['最低价格'],
|
||||
priceTypeName: element['价格取值'],
|
||||
startDate: element['开始日期'],
|
||||
endDate: element['结束日期'],
|
||||
billTypeName: element['计费类型'],
|
||||
statusName: element['启用状态'],
|
||||
feeTypeName: element['费用类型'],
|
||||
currency: element['费用币种'],
|
||||
sendAreaName: element['寄件区域'],
|
||||
dispAreaName: element['派件区域'],
|
||||
exprJson: element['计算规则'],
|
||||
uploadStatus: 0,
|
||||
errorInfo:'',
|
||||
status:1
|
||||
}
|
||||
this.tmpDataList.push(orderData);
|
||||
}
|
||||
this.uploadExcelDataInfo="总共 " + this.tmpDataList.length +" 条数据。";
|
||||
loadingInstance.close()
|
||||
},
|
||||
batchImpDataForm() {
|
||||
// 判断是否有数据
|
||||
if(this.tmpDataList.length==0){
|
||||
this.$modal.msgError('表格中没有数据');
|
||||
return;
|
||||
}
|
||||
//数据转换
|
||||
let newList = this.tmpDataList.map(item => {
|
||||
item.feeType = this.dict.type.emis_fee_type.find(v=>v.label==item.feeTypeName).value;
|
||||
item.priceType = this.dict.type.emis_price_type.find(v=>v.label==item.priceTypeName).value;
|
||||
if(item.billTypeName ==='重量计费'){
|
||||
item.billType='1'
|
||||
}else if(item.billType ==='体积计费'){
|
||||
item.billType='2'
|
||||
}else if(item.billType ==='一口价'){
|
||||
item.billType='3'
|
||||
}
|
||||
item.startDate = this.excelDateToJSDate(item.startDate);
|
||||
item.endDate = this.excelDateToJSDate(item.endDate);
|
||||
return item;
|
||||
})
|
||||
this.total = newList.length;
|
||||
this.emisQuotePriceList = this.emisQuotePriceList.concat(newList);
|
||||
this.tmpDataList=[];
|
||||
this.openUploadForm = false;
|
||||
},
|
||||
cancel(){
|
||||
this.openUploadForm = false;
|
||||
},
|
||||
excelDateToJSDate(excelDate) {
|
||||
// Excel把1900年1月1日存储为数字1
|
||||
const date = new Date(1900, 0, excelDate - 1);
|
||||
// 时间格式化为 YYYY-MM-DD HH:mm:ss
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
},
|
||||
handleBatchAdd() {
|
||||
if (this.ids && this.ids.length > 0) {
|
||||
this.$confirm("确认新增吗?", "提示", {
|
||||
cancelButtonText: "取消",
|
||||
confirmButtonText: "确认",
|
||||
type: "warning",
|
||||
distinguishCancelAndClose: true,
|
||||
closeOnClickModal: false
|
||||
}).then(async () => {
|
||||
if (this.selectionList && this.selectionList.length > 0) {
|
||||
for (let i = 0; i < this.selectionList.length; i++) {
|
||||
let orderItem = this.selectionList[i];
|
||||
//数据转换
|
||||
|
||||
orderItem.feeType = orderItem.feeTypeName;
|
||||
orderItem.billType = orderItem.billTypeName;
|
||||
orderItem.priceType =orderItem.priceTypeName;
|
||||
let res = await draftQuotePrice(orderItem)
|
||||
|
||||
let rstData = res.data;
|
||||
if (rstData.result == 'success') {
|
||||
orderItem.uploadStatus = 1;
|
||||
orderItem.errorInfo = "新增成功";
|
||||
}
|
||||
else {
|
||||
orderItem.uploadStatus = -1;
|
||||
orderItem.errorInfo = rstData.msg;
|
||||
}
|
||||
|
||||
}
|
||||
this.$modal.msgSuccess("上传成功");
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
//标红table指定行
|
||||
tableRowClassName(row, index) {
|
||||
row.row.index = row.rowIndex;
|
||||
if (row.uploadStatus=='1') {
|
||||
return 'success-row';
|
||||
}
|
||||
else if (row.uploadStatus=='-1') {
|
||||
return 'warning-row';
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@ -138,6 +138,7 @@
|
||||
type="primary"
|
||||
plain
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleCopy"
|
||||
>复制规则</el-button>
|
||||
</el-col>
|
||||
|
||||
@ -472,6 +472,7 @@ export default {
|
||||
this.splitChild(this.treeData);
|
||||
this.graph.data(this.treeData);
|
||||
this.graph.render();
|
||||
this.graph.fitCenter();
|
||||
// setTimeout(() => {
|
||||
// this.list = this.list.concat(newlist);
|
||||
// this.edges = this.edges.concat(newEdges);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user