大客户单独报价,批量新增
This commit is contained in:
parent
78810e425a
commit
dced8b657e
@ -155,6 +155,18 @@
|
|||||||
v-hasPermi="['emis:emisQuotePrice:remove']"
|
v-hasPermi="['emis:emisQuotePrice:remove']"
|
||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
</el-col>
|
</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"
|
||||||
|
:disabled="batchAdd"
|
||||||
|
@click="handleBatchAdd"
|
||||||
|
>批量新增</el-button>
|
||||||
|
</el-col>
|
||||||
<!-- <el-col :span="1.5">
|
<!-- <el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="warning"
|
type="warning"
|
||||||
@ -234,7 +246,21 @@
|
|||||||
<el-table-column label="修改人" align="center" prop="updateByName" width="80" :show-overflow-tooltip="true"/>
|
<el-table-column label="修改人" align="center" prop="updateByName" width="80" :show-overflow-tooltip="true"/>
|
||||||
<el-table-column label="修改网点" align="center" prop="updateSiteName" width="80" :show-overflow-tooltip="true"/>
|
<el-table-column label="修改网点" align="center" prop="updateSiteName" width="80" :show-overflow-tooltip="true"/>
|
||||||
<el-table-column label="修改时间" align="center" prop="updateTime" width="170"/>
|
<el-table-column label="修改时间" align="center" prop="updateTime" width="170"/>
|
||||||
|
<el-table-column label="计算规则" align="center" prop="exprJson" width="470"/>
|
||||||
|
<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="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
@ -264,14 +290,48 @@
|
|||||||
<el-dialog :title="titleBatchForm" :visible.sync="openBatchUpdateForm" width="50%" :destroy-on-close="true" :close-on-click-modal="false" v-dialogDrag append-to-body>
|
<el-dialog :title="titleBatchForm" :visible.sync="openBatchUpdateForm" width="50%" :destroy-on-close="true" :close-on-click-modal="false" v-dialogDrag append-to-body>
|
||||||
<BatchQuotePriceUpdateForm :ids="ids" @on-changed="handleBatchFormChanged" @on-cancel="cancelBatchForm"></BatchQuotePriceUpdateForm>
|
<BatchQuotePriceUpdateForm :ids="ids" @on-changed="handleBatchFormChanged" @on-cancel="cancelBatchForm"></BatchQuotePriceUpdateForm>
|
||||||
</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/imp_trans_quote.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>
|
</XdPageContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters } from 'vuex'
|
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 elDateSimplePicker from '@/components/DatePickerAdv/elDateSimplePicker';
|
||||||
import vipTransQuotePriceForm from '@/views/emis/emisQuotePrice/vipTransQuotePriceForm';
|
import vipTransQuotePriceForm from '@/views/emis/emisQuotePrice/vipTransQuotePriceForm';
|
||||||
|
|
||||||
@ -288,8 +348,7 @@ import TransProductPicker from '@/views/emis/EmisBaseTools/TransProductPicker.vu
|
|||||||
import EmisMonthpayAccountPicker from '@/views/emis/EmisBaseTools/EmisMonthpayAccountPicker.vue';
|
import EmisMonthpayAccountPicker from '@/views/emis/EmisBaseTools/EmisMonthpayAccountPicker.vue';
|
||||||
|
|
||||||
import BatchQuotePriceUpdateForm from '@/views/emis/emisQuotePrice/batchQuotePriceUpdateForm.vue';
|
import BatchQuotePriceUpdateForm from '@/views/emis/emisQuotePrice/batchQuotePriceUpdateForm.vue';
|
||||||
|
import XLSX from 'xlsx'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "VipTransQuotePriceList",
|
name: "VipTransQuotePriceList",
|
||||||
components: { elDateSimplePicker,EmisMonthpayAccountPicker,vipTransQuotePriceForm,CountryPicker,
|
components: { elDateSimplePicker,EmisMonthpayAccountPicker,vipTransQuotePriceForm,CountryPicker,
|
||||||
@ -325,11 +384,15 @@ export default {
|
|||||||
formulaType:1,
|
formulaType:1,
|
||||||
|
|
||||||
chargeType:null,
|
chargeType:null,
|
||||||
|
openBatchUpdateForm:false,
|
||||||
|
titleBatchForm: "",
|
||||||
|
form:{},
|
||||||
|
rules:{},
|
||||||
openForm: false,
|
openForm: false,
|
||||||
titleForm: "",
|
titleForm: "",
|
||||||
isCopy: false,
|
isCopy: false,
|
||||||
|
fileName:"",
|
||||||
|
fileList:[],
|
||||||
openBatchUpdateForm:false,
|
openBatchUpdateForm:false,
|
||||||
titleBatchForm: "",
|
titleBatchForm: "",
|
||||||
|
|
||||||
@ -338,6 +401,16 @@ export default {
|
|||||||
// 弹出展示层
|
// 弹出展示层
|
||||||
titleView:"",
|
titleView:"",
|
||||||
openView: false,
|
openView: false,
|
||||||
|
//批量录入弹出
|
||||||
|
openUploadForm:false,
|
||||||
|
uploadMsg:"",
|
||||||
|
uploadExcelDataInfo:"",
|
||||||
|
//导入模板列表表格数据
|
||||||
|
tmpDataList: [],
|
||||||
|
selectionList:[],
|
||||||
|
selectionIndexList: [],
|
||||||
|
// 非批量新增禁用
|
||||||
|
batchAdd:true,
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
@ -400,7 +473,9 @@ export default {
|
|||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getUUID() {
|
||||||
|
return Math.random().toString(36).substring(3, 10);
|
||||||
|
},
|
||||||
/** 查询费用报价列表 */
|
/** 查询费用报价列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
@ -415,6 +490,7 @@ export default {
|
|||||||
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
|
this.batchAdd=true;
|
||||||
this.queryParams.pageNum = 1;
|
this.queryParams.pageNum = 1;
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
@ -425,6 +501,7 @@ export default {
|
|||||||
},
|
},
|
||||||
// 多选框选中数据
|
// 多选框选中数据
|
||||||
handleSelectionChange(selection) {
|
handleSelectionChange(selection) {
|
||||||
|
this.selectionList = selection;
|
||||||
this.ids = selection.map(item => item.quoteId)
|
this.ids = selection.map(item => item.quoteId)
|
||||||
let [lastObj]=selection.slice(-1);
|
let [lastObj]=selection.slice(-1);
|
||||||
this.currentQuote=lastObj;
|
this.currentQuote=lastObj;
|
||||||
@ -452,10 +529,12 @@ export default {
|
|||||||
|
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
|
if( row.quoteId || this.ids.filter(Boolean).length>1){
|
||||||
this.currentId = row.quoteId || this.ids;
|
this.currentId = row.quoteId || this.ids;
|
||||||
this.openForm = true;
|
this.openForm = true;
|
||||||
this.isCopy = false;
|
this.isCopy = false;
|
||||||
this.titleForm = "修改干线运输费";
|
this.titleForm = "修改干线运输费";
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleBatchUpdate(row) {
|
handleBatchUpdate(row) {
|
||||||
@ -549,6 +628,149 @@ export default {
|
|||||||
dateTimeChange(value){
|
dateTimeChange(value){
|
||||||
this.dateTimeRange=value;
|
this.dateTimeRange=value;
|
||||||
},
|
},
|
||||||
|
batchImpDataForm() {
|
||||||
|
this.batchAdd = false;
|
||||||
|
// 判断是否有数据
|
||||||
|
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;
|
||||||
|
},
|
||||||
|
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, quoteType: 3 }) // 3-大客户运输费
|
||||||
|
|
||||||
|
let rstData = res.data;
|
||||||
|
if (rstData.result == 'success') {
|
||||||
|
orderItem.uploadStatus = 1;
|
||||||
|
orderItem.errorInfo = "新增成功";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
orderItem.uploadStatus = -1;
|
||||||
|
orderItem.errorInfo = rstData.msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
this.$modal.msgSuccess("上传成功");
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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
|
||||||
|
},
|
||||||
|
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}`;
|
||||||
|
},
|
||||||
|
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()
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user