订单导入

product
杨世强 2 years ago
parent d3cd0b5662
commit b085cf19bd

@ -8,6 +8,7 @@ import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jnpf.arinvoices.entity.Arinvoices_item0Entity;
import jnpf.base.ActionResult;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
@ -21,6 +22,8 @@ import jnpf.customer.service.CustomerService;
import jnpf.exception.DataException;
import jnpf.materialvo.entity.MaterialEntity;
import jnpf.materialvo.service.MaterialService;
import jnpf.purchaseorder.entity.PurchaseOrderImportVo;
import jnpf.purchaseorder.model.purchaseorder.PurchaseorderDTO;
import jnpf.vehicle.entity.VehicleEntity;
import jnpf.vehicle.service.VehicleService;
import org.apache.commons.lang3.ObjectUtils;
@ -47,12 +50,14 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import jnpf.util.GeneraterSwapUtil;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.*;
import jnpf.util.file.UploadUtil;
@ -257,8 +262,8 @@ public class PoundlistController {
UserInfo userInfo=userProvider.get();
DownloadVO vo=DownloadVO.builder().build();
try{
vo.setName("职员信息.xlsx");
vo.setUrl(UploaderUtil.uploaderFile("/api/Common/DownloadModel?encryption=" ,userInfo.getId()+"#"+"职员信息.xlsx"+"#"+"Temporary"));
vo.setName("订单数据模板.xlsx");
vo.setUrl(UploaderUtil.uploaderFile("/api/Common/DownloadModel?encryption=" ,userInfo.getId()+"#"+"poundlist_import_template.xlsx"+"#"+"Temporary"));
}catch(Exception e){
log.error("信息导出Excel错误:{}" ,e.getMessage());
}
@ -599,6 +604,66 @@ public class PoundlistController {
}
/**
* (excel)
*
* @return
*/
@ApiOperation("上传文件")
@PostMapping("/Uploader")
public ActionResult Uploader() {
List<MultipartFile> list = UpUtil.getFileAll();
MultipartFile file = list.get(0);
if (file.getOriginalFilename().endsWith(".xlsx") || file.getOriginalFilename().endsWith(".xls")) {
String filePath = configValueUtil.getTemporaryFilePath();
String fileName = RandomUtil.uuId() + "." + UpUtil.getFileType(file);
fileName = XSSEscape.escape(fileName);
//上传文件
FileUtil.upFile(file, filePath, fileName);
DownloadVO vo = DownloadVO.builder().build();
vo.setName(fileName);
return ActionResult.success(vo);
} else {
return ActionResult.fail("选择文件不符合导入");
}
}
/**
*
*
* @return
*/
@ApiOperation("导入预览")
@GetMapping("/ImportPreview")
public ActionResult ImportPreview(String fileName) {
String filePath = configValueUtil.getTemporaryFilePath();
File temporary = new File(XSSEscape.escapePath(filePath + fileName));
//得到数据
List<PoundlistEntity> personList = ExcelUtil.importExcel(temporary, 0, 1, PoundlistEntity.class);
//预览数据
Map<String, Object> map = poundlistService.importPreview(personList);
return ActionResult.success(map);
}
/**
*
*
* @return
*/
@ApiOperation("导入数据")
@PostMapping("/ImportData")
public ActionResult ImportData(@RequestBody PoundlistDTO data) throws ParseException, DataException {
List<PoundlistDTO> dataList = JsonUtil.getJsonToList(data.getList(), PoundlistDTO.class);
//导入数据
PoundlistImportVo result = poundlistService.importData(dataList);
System.out.println("这是错误的数据"+result);
Map<String, Object> stringObjectMap = JsonUtil.entityToMap(result);
return ActionResult.success(stringObjectMap);
}

@ -1,5 +1,6 @@
package jnpf.poundlist.entity;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
@ -89,12 +90,15 @@ public class PoundlistEntity {
@TableField("ADVANCE")
private String advance;
@Excel(name = "单位")
@TableField("UNIT")
private String unit;
@Excel(name = "毛重")
@TableField("GROSS_WEIGHT")
private BigDecimal grossWeight;
@Excel(name = "皮重")
@TableField("TARE_WEIGHT")
private BigDecimal tareWeight;
@ -104,6 +108,7 @@ public class PoundlistEntity {
@TableField("NET_WEIGHT")
private BigDecimal netWeight;
@Excel(name = "结算重量")
@TableField("SETTLEMENT")
private BigDecimal settlement;
@ -113,6 +118,7 @@ public class PoundlistEntity {
@TableField("COLLECT_PRICE")
private BigDecimal collectPrice;
@Excel(name = "销售单价")
@TableField("SALES_PRICE")
private BigDecimal salesPrice;
@ -191,12 +197,14 @@ public class PoundlistEntity {
@TableField(exist = false)
private String materialName;
@Excel(name = "客户名称")
@TableField(exist = false)
private String customerName;
@TableField(exist = false)
private String salesName;
@Excel(name = "车号")
@TableField(exist = false)
private String vehicleName;
@ -247,4 +255,8 @@ public class PoundlistEntity {
private String poundlistId;
@TableField(exist = false)
private String ContractName;
@Excel(name = "销售金额")
@TableField(exist = false)
private String salesAmount;
}

@ -0,0 +1,35 @@
package jnpf.poundlist.entity;
import jnpf.poundlist.model.poundlist.PoundlistDTO;
import jnpf.purchaseorder.model.purchaseorder.PurchaseorderDTO;
import lombok.Data;
import java.util.List;
/**
* @Author: WangChuang
* @Date: 2/3/2023 3:47
* @Description //注释:
* @Version 1.0
*/
@Data
public class PoundlistImportVo {
/**
*
*/
private int snum;
/**
*
*/
private int fnum;
/**
* (0, 1)
*/
private int resultType;
/**
*
*/
private List<PoundlistDTO> failResult;
private List<PoundlistEntity> poundlistEntityList;
}

@ -0,0 +1,64 @@
package jnpf.poundlist.model.poundlist;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonProperty;
import jnpf.purchaseorder.model.purchaseorder.PurchaseorderDTO;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
*
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
* @ 2023-02-21
*/
@Data
public class PoundlistDTO implements Cloneable{
@Excel(name = "客户名称")
private String customerName;
@Excel(name = "车号")
private String vehicleName;
@Excel(name = "毛重")
private String grossWeight;
@Excel(name = "皮重")
private String tareWeight;
@Excel(name = "结算重量")
private String settlement;
@Excel(name = "单位")
private String unit;
@Excel(name = "销售单价")
private String salesPrice;
@Excel(name = "销售金额")
private String salesAmount;
@Excel(name = "错误原因")
private String causeError;
private List<PoundlistDTO> list;
@Override
public PoundlistDTO clone() throws CloneNotSupportedException {
try {
PoundlistDTO clone = (PoundlistDTO) super.clone();
// TODO: copy mutable state here, so the clone can't change the internals of the original
return clone;
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
}
}

@ -1,10 +1,18 @@
package jnpf.poundlist.service;
import jnpf.arinvoices.entity.Arinvoices_item0Entity;
import jnpf.exception.DataException;
import jnpf.poundlist.entity.PoundlistEntity;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.poundlist.entity.PoundlistImportVo;
import jnpf.poundlist.entity.PoundlistSEntity;
import jnpf.poundlist.entity.PoundlistTwoEntity;
import jnpf.poundlist.model.poundlist.PoundlistDTO;
import jnpf.poundlist.model.poundlist.PoundlistPagination;
import jnpf.purchaseorder.entity.PurchaseOrderImportVo;
import jnpf.purchaseorder.model.purchaseorder.PurchaseorderDTO;
import java.text.ParseException;
import java.util.*;
/**
*
@ -43,4 +51,14 @@ public interface PoundlistService extends IService<PoundlistEntity> {
// 子表方法
//列表子表数据方法
/**
*
*
* @param personList
* @return
*/
Map<String, Object> importPreview(List<PoundlistEntity> personList);
PoundlistImportVo importData(List<PoundlistDTO> dataList) throws ParseException, DataException;
}

@ -1,19 +1,34 @@
package jnpf.poundlist.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import jnpf.Jg_natural.entity.Jg_naturalEntity;
import jnpf.arinvoices.entity.Arinvoices_item0Entity;
import jnpf.base.ActionResult;
import jnpf.base.UserInfo;
import jnpf.base.controller.BillRuleController;
import jnpf.base.entity.ProvinceEntity;
import jnpf.contractfile.entity.ContractFileEntity;
import jnpf.contractfile.service.ContractFileService;
import jnpf.customer.entity.CustomerEntity;
import jnpf.customer.service.CustomerService;
import jnpf.exception.DataException;
import jnpf.materialvo.entity.MaterialEntity;
import jnpf.materialvo.service.MaterialService;
import jnpf.model.UserGetUserEntity;
import jnpf.poundlist.entity.*;
import jnpf.poundlist.mapper.PoundlistMapper;
import jnpf.poundlist.model.poundlist.PoundlistDTO;
import jnpf.poundlist.model.poundlist.PoundlistListVO;
import jnpf.poundlist.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.purchaseorder.entity.PurchaseOrderImportVo;
import jnpf.purchaseorder.entity.Purchaseorder_item0Entity;
import jnpf.purchaseorder.entity.PurchaseorderitemEntity;
import jnpf.purchaseorder.model.purchaseorder.PurchaseorderDTO;
import jnpf.supplier.entity.SupplierEntity;
import jnpf.supplier.service.SupplierService;
import jnpf.supplyProcessAnalysis.entity.ContractMEntity;
import jnpf.util.RandomUtil;
import java.math.BigDecimal;
@ -30,11 +45,16 @@ import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import java.math.RoundingMode;
import java.text.ParseException;
import java.util.stream.Collectors;
import jnpf.util.context.SpringContext;
import jnpf.vehicle.entity.VehicleEntity;
import jnpf.vehicle.service.VehicleService;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
@ -77,6 +97,9 @@ public class PoundlistServiceImpl extends ServiceImpl<PoundlistMapper, Poundlist
@Autowired
private MaterialService materialService;
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Override
public List<PoundlistEntity> getList(PoundlistPagination poundlistPagination) {
String userId = userProvider.get().getUserId();
@ -295,6 +318,205 @@ public class PoundlistServiceImpl extends ServiceImpl<PoundlistMapper, Poundlist
return poundlistMapper.queryPoundListByIdsRenkuan(poundlistIdList, paymentdocId);
}
@Override
public Map<String, Object> importPreview(List<PoundlistEntity> personList) {
List<Map<String, Object>> dataRow = new ArrayList<>();
List<Map<String, Object>> columns = new ArrayList<>();
if(personList != null) {
for (int i = 0; i < personList.size(); i++) {
Map<String, Object> dataRowMap = new HashMap<>();
PoundlistEntity model = personList.get(i);
dataRowMap.put("customerName", model.getCustomerName());
dataRowMap.put("vehicleName", model.getVehicleName());
dataRowMap.put("grossWeight", model.getGrossWeight());
dataRowMap.put("tareWeight", model.getTareWeight());
dataRowMap.put("settlement", model.getSettlement());
dataRowMap.put("unit", model.getUnit());
dataRowMap.put("salesPrice", model.getSalesPrice());
dataRowMap.put("salesAmount", model.getSalesAmount());
dataRow.add(dataRowMap);
}
for (int i = 1; i < 10; i++) {
Map<String, Object> columnsMap = new HashMap<>();
columnsMap.put("AllowDBNull", true);
columnsMap.put("AutoIncrement", false);
columnsMap.put("AutoIncrementSeed", 0);
columnsMap.put("AutoIncrementStep", 1);
columnsMap.put("Caption", this.getColumns(i));
columnsMap.put("ColumnMapping", 1);
columnsMap.put("ColumnName", this.getColumns(i));
columnsMap.put("Container", null);
columnsMap.put("DataType", "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
columnsMap.put("DateTimeMode", 3);
columnsMap.put("DefaultValue", null);
columnsMap.put("DesignMode", false);
columnsMap.put("Expression", "");
columnsMap.put("ExtendedProperties", "");
columnsMap.put("MaxLength", -1);
columnsMap.put("Namespace", "");
columnsMap.put("Ordinal", 0);
columnsMap.put("Prefix", "");
columnsMap.put("ReadOnly", false);
columnsMap.put("Site", null);
columnsMap.put("Table", personList);
columnsMap.put("Unique", false);
columns.add(columnsMap);
}
}
Map<String, Object> map = new HashMap<>();
map.put("dataRow", dataRow);
map.put("columns", columns);
return map;
}
private String getColumns(Integer key) {
Map<Integer, String> map = new HashMap<>();
map.put(1, "客户名称");
map.put(2, "车号");
map.put(3, "毛重");
map.put(4, "皮重");
map.put(5, "结算重量");
map.put(6, "单位");
map.put(7, "销售单价");
map.put(8, "销售金额");
return map.get(key);
}
/**
*
*
* @param dataList
* @return
*/
@Transactional(rollbackFor = Exception.class)
@Override
public PoundlistImportVo importData(List<PoundlistDTO> dataList) throws ParseException, DataException {
//记录成功了几条
int sum = 0;
//记录失败了几条
int num = 0;
List<PoundlistEntity> poundlistEntityList = new ArrayList<>();
List<PoundlistDTO> errList = new ArrayList<>();
for (int i = 0; i < dataList.size(); i++) {
PoundlistDTO model = dataList.get(i);
PoundlistDTO dto = null;
try {
dto = model.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
if (StringUtils.isNotEmpty(model.getCustomerName())) {
String userId = userProvider.get().getUserId();
String departmentId = userProvider.getDepartmentId(userId);
LambdaQueryWrapper<CustomerEntity> customerWrapper = new LambdaQueryWrapper<>();
customerWrapper.eq(CustomerEntity::getDepartmentId,departmentId);
customerWrapper.eq(CustomerEntity::getSupplierNm,model.getCustomerName());
CustomerEntity customerEntity = customerService.getOne(customerWrapper);
String customerId = "";
if (ObjectUtils.isNotEmpty(customerEntity) && StringUtils.isNotEmpty(customerEntity.getId())){
customerId = customerEntity.getId();
}else{
dto.setCauseError("未查询到客户,请检查客户名称是否正确");
errList.add(dto);
continue;
}
if (StringUtils.isNotEmpty(model.getVehicleName())) {
LambdaQueryWrapper<VehicleEntity> vehicleWrapper = new LambdaQueryWrapper<>();
vehicleWrapper.eq(VehicleEntity::getTicketno,model.getVehicleName());
vehicleWrapper.eq(VehicleEntity::getDepartmentId,departmentId);
List<VehicleEntity> vehicleList = vehicleService.list(vehicleWrapper);
if (vehicleList == null || vehicleList.size() == 0){
dto.setCauseError("未查询到车号,请检查车号是否正确");
errList.add(dto);
continue;
}
if (StringUtils.isNotEmpty(model.getGrossWeight()) || StringUtils.isNotEmpty(model.getTareWeight()) || StringUtils.isNotEmpty(model.getSettlement()) || StringUtils.isNotEmpty(model.getUnit())) {
if (model.getUnit() != null) {
if (model.getUnit().equals("吨") || model.getUnit().equals("T")) {
model.setUnit("0");
}
if (model.getUnit().equals("千克") || model.getUnit().equals("KG")) {
model.setUnit("1");
}
}
List<String> vehicleId = new ArrayList<>();
for (VehicleEntity entity : vehicleList){
vehicleId.add(entity.getId());
}
LambdaQueryWrapper<PoundlistEntity> poundlistWrapper = new LambdaQueryWrapper<>();
poundlistWrapper.eq(PoundlistEntity::getCustomerId,customerId);
poundlistWrapper.eq(PoundlistEntity::getGrossWeight,model.getGrossWeight());
poundlistWrapper.eq(PoundlistEntity::getTareWeight,model.getTareWeight());
poundlistWrapper.eq(PoundlistEntity::getSettlement,model.getSettlement());
poundlistWrapper.eq(PoundlistEntity::getUnit,model.getUnit());
poundlistWrapper.in(PoundlistEntity::getVehicleId,vehicleId);
List<PoundlistEntity> poundlistList = poundlistMapper.selectList(poundlistWrapper);
if (poundlistList != null && poundlistList.size() != 0){
if (poundlistList.size() == 1){
PoundlistEntity poundlistEntity = JsonUtil.getJsonToBean(poundlistList.get(0),PoundlistEntity.class);
poundlistEntity.setDocumentNo(generaterSwapUtil.getBillNumber("salesOrder", false));
ContractFileEntity entity = contractFileService.getInfo(poundlistEntity.getSalesId());
if (ObjectUtils.isNotEmpty(entity) && StringUtils.isNotEmpty(entity.getContractNo())) {
poundlistEntity.setContractNo(entity.getContractNo());
poundlistEntity.setContractName(entity.getContractName());
}
CustomerEntity customer = customerService.getInfo(poundlistEntity.getCustomerId());
if (ObjectUtils.isNotEmpty(customer) && StringUtils.isNotEmpty(customerEntity.getSupplierNm())){
poundlistEntity.setCustomerName(customer.getSupplierNm());
}
VehicleEntity vehicleEntity = vehicleService.getInfo(poundlistEntity.getVehicleId());
if (ObjectUtils.isNotEmpty(vehicleEntity) && StringUtils.isNotEmpty(vehicleEntity.getTicketno())){
poundlistEntity.setVehicleName(vehicleEntity.getTicketno());
}
MaterialEntity materialEntity = materialService.getInfo(poundlistEntity.getMaterialId());
if (ObjectUtils.isNotEmpty(materialEntity) && StringUtils.isNotEmpty(materialEntity.getItemName())){
poundlistEntity.setMaterialName(materialEntity.getItemName());
}
poundlistEntity.setRate("0");
poundlistEntity.setUnitPrice(new BigDecimal(model.getSalesPrice()));
poundlistEntity.setPrice(new BigDecimal(model.getSalesAmount()));
poundlistEntityList.add(poundlistEntity);
sum++;
}else{
dto.setCauseError("【车号-"+model.getVehicleName()+"】出现重复数据,请查验");
errList.add(dto);
}
}else{
dto.setCauseError("未查询到磅单");
errList.add(dto);
}
}else{
dto.setCauseError("毛重或皮重或结算重量或单位不能为空");
errList.add(dto);
}
}else{
dto.setCauseError("车号不能为空");
errList.add(dto);
}
}else{
dto.setCauseError("客户名称不能为空");
errList.add(dto);
}
}
PoundlistImportVo importVo = new PoundlistImportVo();
num = errList.size();
importVo.setSnum(sum);
importVo.setFnum(num);
importVo.setFailResult(errList);
if (errList.size() > 0) {
importVo.setResultType(1);
} else {
importVo.setResultType(0);
importVo.setPoundlistEntityList(poundlistEntityList);
}
return importVo;
}
@Override
public void delete(PoundlistEntity entity) {
if (entity != null) {

@ -0,0 +1,25 @@
import request from '@/utils/request'
// 导入
export function ImportData(data) {
return request({
url: '/api/poundlist/Poundlist/ImportData',
method: 'post',
data
})
}
// 导入预览
export function ImportPreview(data) {
return request({
url: '/api/poundlist/Poundlist/ImportPreview',
method: 'get',
data
})
}
//模板下载
export function TemplateDownload() {
return request({
url: '/api/poundlist/Poundlist/templateDownload',
method: 'get'
})
}

@ -0,0 +1,243 @@
<template>
<el-dialog title="批量导入" :close-on-click-modal="false" :visible.sync="visible"
class="JNPF-dialog JNPF-dialog_center JNPF-dialog-import" lock-scroll width="1000px" :modal="false" :modal-append-to-body="false">
<el-steps :active="active" align-center>
<el-step title="上传文件"></el-step>
<el-step title="数据预览"></el-step>
<el-step title="导入数据"></el-step>
</el-steps>
<div class="import-main" v-show="active==1">
<div class="upload">
<div class="up_left">
<img src="@/assets/images/upload.png">
</div>
<div class="up_right">
<p class="title">上传填好的数据表</p>
<p class="tip">文件后缀名必须是xls或xlsx文件大小不超过500KB最多支持导入1000条数据</p>
<el-upload :action="define.comUrl+'/api/invoices/Invoices/Uploader'"
:headers="{ Authorization: $store.getters.token}" :on-success="handleSuccess"
:on-remove="handleRemove" :before-remove="beforeRemove" :on-change="handleChange"
:file-list="fileList" accept=".xls,.xlsx" :before-upload="beforeUpload"
class="upload-area">
<el-button type="text">上传文件</el-button>
</el-upload>
</div>
</div>
<div class="upload">
<div class="up_left">
<img src="@/assets/images/import.png">
</div>
<div class="up_right">
<p class="title">填写导入数据信息</p>
<p class="tip">请按照数据模板的格式准备导入数据模板中的表头名称不可更改表头行不能删除</p>
<el-button type="text" @click="templateDownload"></el-button>
</div>
</div>
</div>
<div class="import-main" v-show="active==2">
<JNPF-table v-loading="listLoading" :data="list">
<el-table-column prop="customerName" label="客户名称" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.customerName" />
</template>
</el-table-column>
<el-table-column prop="vehicleName" label="车号" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.vehicleName" />
</template>
</el-table-column>
<el-table-column prop="grossWeight" label="毛重" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.grossWeight" />
</template>
</el-table-column>
<el-table-column prop="tareWeight" label="皮重" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.tareWeight" />
</template>
</el-table-column>
<el-table-column prop="settlement" label="结算重量" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.settlement" />
</template>
</el-table-column>
<el-table-column prop="unit" label="单位" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.unit" />
</template>
</el-table-column>
<el-table-column prop="salesPrice" label="销售单价" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.salesPrice" />
</template>
</el-table-column>
<el-table-column prop="salesAmount" label="销售金额" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.salesAmount" />
</template>
</el-table-column>
<el-table-column label="操作" width="50">
<template slot-scope="scope">
<el-button size="mini" type="text" class="JNPF-table-delBtn"
@click="handleDel(scope.$index)">删除</el-button>
</template>
</el-table-column>
</JNPF-table>
</div>
<div class="import-main" v-show="active==3">
<div class="success" v-if="!result.resultType">
<img src="@/assets/images/success.png" alt="">
<p class="success-title">批量导入成功</p>
<p class="success-tip">您已成功导入数据</p>
</div>
<div class="unsuccess" v-if="result.resultType">
<el-alert title="错误提醒:导入失败数据展示" type="warning" show-icon :closable="false" />
<div class="upload error-show">
<div class="up_left">
<img class="" src="@/assets/images/tip.png">
</div>
<div class="up_right">
<p class="tip">正常数量条数<el-link type="success" :underline="false">{{result.snum}}
</el-link>
</p>
<p class="tip">异常数量条数<el-link type="danger" :underline="false">{{result.fnum}}
</el-link>
</p>
</div>
</div>
<p class="contips">以下文件数据为导入异常数据</p>
<JNPF-table :data="resultList" height="280px">
<el-table-column prop="customerName" label="客户名称" width="100" />
<el-table-column prop="vehicleName" label="车号" width="100" />
<el-table-column prop="grossWeight" label="毛重" width="80" />
<el-table-column prop="tareWeight" label="皮重" width="120" />
<el-table-column prop="settlement" label="结算重量" width="120" />
<el-table-column prop="unit" label="单位" width="100" />
<el-table-column prop="salesPrice" label="销售单价" width="150" />
<el-table-column prop="salesAmount" label="销售金额" width="150" />
<el-table-column prop="causeError" label="错误原因" width="100" />
</JNPF-table>
</div>
</div>
<JNPF-Form ref="JNPFForm" />
<span slot="footer" class="dialog-footer">
<el-button @click="cancel()" v-if="active == 1"> </el-button>
<el-button @click="prev" v-if="active == 2"></el-button>
<el-button @click="next" type="primary" v-if="active < 3" :loading="btnLoading"
:disabled="active == 1 && !fileName">下一步
</el-button>
<el-button @click="cancel(true)" type="primary" v-else> </el-button>
</span>
</el-dialog>
</template>
<script>
import { TemplateDownload, ImportData, ImportPreview } from '@/api/scm/poundlist'
import JNPFForm from './salesForm'
export default {
components: {
JNPFForm,
},
data() {
return {
visible: false,
btnLoading: false,
listLoading: false,
fileName: '',
fileList: [],
active: 1,
list: [],
resultList: [],
result: {
resultType: 0,
snum: 0,
fnum: 0
}
}
},
methods: {
prev() {
if (this.active == 1) return
this.active--
},
next() {
if (this.active == 2) {
if (!this.list.length) return this.$message({ message: '导入数据为空', type: 'warning' })
this.btnLoading = true
// this.btnLoading = false
// this.result = this.list
console.log('rrrrrrr', this.list);
//this.$emit('importData', this.list)
// this.active++
ImportData({ list: this.list }).then(res => {
debugger
if (res.data.resultType == 0){
this.btnLoading = false
this.$nextTick(() => {
this.$refs.JNPFForm.init2(res.data.poundlistEntityList)
})
}else if (res.data.resultType == 1) {
this.result = res.data
this.resultList = res.data.failResult
this.btnLoading = false
this.active++
}
}).catch(() => { this.btnLoading = false })
}
if (this.active == 1) {
if (!this.fileList.length || !this.fileName) return this.$message({ message: '请先上传文件', type: 'warning' })
this.btnLoading = true
ImportPreview({ fileName: this.fileName }).then(res => {
this.list = res.data.dataRow
this.btnLoading = false
this.active++
}).catch(() => { this.btnLoading = false })
}
},
cancel(isRefresh) {
this.visible = false
this.$emit('importData', {
checkedList: this.result
})
//if (isRefresh) this.$emit('refresh')
},
init() {
this.active = 1
this.fileList = []
this.fileName = ''
this.visible = true
},
handleDel(index) {
this.list.splice(index, 1)
},
templateDownload() {
TemplateDownload().then(res => {
this.jnpf.downloadFile(res.data.url)
})
},
beforeUpload(file) {
let isRightSize = file.size / 1024 < 500
if (!isRightSize) this.$message.error(`文件大小不能超过500KB`)
return isRightSize
},
handleRemove(file, fileList) {
this.fileList = []
},
beforeRemove(file, fileList) {
return this.$confirm(`确定移除 ${file.name}`).catch(() => { })
},
handleChange(file, fileList) {
this.fileList = fileList.slice(-1)
},
handleSuccess(res, file, fileList) {
if (res.code == 200) {
this.fileList = fileList.slice(-1)
this.fileName = res.data.name
} else {
this.fileList = fileList.filter(o => o.uid != file.uid)
this.$message({ message: res.msg, type: 'error', duration: 1000 })
}
},
}
}
</script>

@ -120,6 +120,8 @@
<el-button type="text" icon="el-icon-check" @click="handleBatchCaigou()" v-has="'btn_handleBatchCaigou'">
</el-button>
<el-button type="text" icon="el-icon-close" @click="createSale()" v-has="'btn_createSale'">
</el-button>
<el-button type="text" icon="el-icon-plus" @click="orderImport()" v-has="'btn_createSale'">
</el-button>
</div>
<div class="JNPF-common-head-right">
@ -272,6 +274,7 @@
<JNPF-Form6 v-if="formVisible6" ref="JNPFForm6" @refresh="refresh6" />
<ExportBox v-if="exportBoxVisible" ref="ExportBox" @download="download" />
<Detail v-if="detailVisible" ref="Detail" @refresh="detailVisible=false" />
<ImportForm v-if="importFormVisible" ref="importForm" @refresh="reset()" />
</div>
</template>
@ -283,13 +286,13 @@
import JNPFForm from './Form'
import JNPFForm2 from './PurchaseOrderForm'
import JNPFForm4 from './salesForm'
import JNPFForm6 from './VechicleForm'
import ExportBox from './ExportBox'
import {
getDataInterfaceRes
} from '@/api/systemData/dataInterface'
import Detail from './Detail'
import ImportForm from './ImportForm'
export default {
components: {
@ -298,10 +301,12 @@
JNPFForm4,
JNPFForm6,
ExportBox,
Detail
Detail,
ImportForm
},
data() {
return {
importFormVisible: false,
showAll: false,
detailVisible: false,
query: {
@ -513,6 +518,12 @@
this.initData()
},
methods: {
orderImport(){
this.importFormVisible = true
this.$nextTick(() => {
this.$refs.importForm.init()
})
},
getSummaries(param) {
const { columns, data } = param;
const sums = [];

@ -1029,6 +1029,44 @@
this.dataForm.price = amount
this.$store.commit('generator/UPDATE_RELATION_DATA', {})
},
init2(list) {
this.visible = true
this.dataForm.salesorder_item0List = list
this.dataForm.documentNo = list[0].documentNo
this.dataForm.contractId = list[0].salesId
this.dataForm.customerId = list[0].customerId
this.dataForm.contractNo = list[0].contractNo
this.dataForm.contractName = list[0].contractName
this.dataForm.customerName = list[0].customerName
this.dataForm.isTransfer = list.isTransfer
this.dataForm.purchaseOrderId = list.purchaseOrderId
debugger
var num = 0
var amount = 0
var advance = 0
var notPrice = 0
for (let i = 0; i < list.length; i++) {
// this.dataForm.salesorder_item0List[i].unitPrice = list[i].salesPrice;
this.dataForm.salesorder_item0List[i].poundlistId = list[i].id
this.dataForm.salesorder_item0List[i].price = list[i].price.toFixed(2)
this.rateOptions.find((item) => {
if (this.dataForm.salesorder_item0List[i].rate == item.id) {
this.dataForm.salesorder_item0List[i].noPrice = this.jnpf.floatDiv(this.dataForm.salesorder_item0List[i].price, this.jnpf.floatAdd(1, this.jnpf.floatDiv(item.fullName,100))).toFixed(2)
notPrice = this.jnpf.floatAdd(notPrice, this.dataForm.salesorder_item0List[i].noPrice)
}
})
if (list[i].advance == 1) {
advance = this.jnpf.floatAdd(advance, this.jnpf.floatMul(list[i].salesPrice, list[i].settlement)).toFixed(2)
}
num = this.jnpf.floatAdd(num, list[i].settlement)
amount = this.jnpf.floatAdd(amount, list[i].price)
}
this.dataForm.notPrice = notPrice
this.dataForm.advanceAmount = advance
this.dataForm.num = num
this.dataForm.price = amount
this.$store.commit('generator/UPDATE_RELATION_DATA', {})
},
//
dataFormSubmit() {
this.$refs['elForm'].validate((valid) => {

Loading…
Cancel
Save