导入和导入模板上传

product
tengxi 2 years ago
parent 312f7d9e14
commit aea8863eb3

@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
import jnpf.base.ActionResult;
import jnpf.base.NoDataSourceBind;
import jnpf.base.UserInfo;
import jnpf.base.entity.BillRuleEntity;
import jnpf.base.util.OptimizeUtil;
import jnpf.base.vo.DownloadVO;
import jnpf.base.vo.PageListVO;
@ -27,9 +28,14 @@ import jnpf.contractfile.service.ContractFileService;
import jnpf.contractfile.service.Contract_item0Service;
import jnpf.contractfile.service.Contract_item1Service;
import jnpf.exception.DataException;
import jnpf.model.EmployeeModel;
import jnpf.model.UploaderVO;
import jnpf.model.employee.EmployeeImportVO;
import jnpf.permission.model.user.vo.UserExportVO;
import jnpf.permission.model.user.vo.UserImportVO;
import jnpf.util.*;
import jnpf.util.enums.FileTypeEnum;
import jnpf.util.enums.ModuleTypeEnum;
import jnpf.util.file.UploadUtil;
import jnpf.utils.YozoUtils;
import lombok.Cleanup;
@ -44,6 +50,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.Valid;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -52,8 +59,8 @@ import java.util.List;
import java.util.Map;
/**
*
* contractFile
*
* @ V3.2.0
* @ LINKAGE-BOOT
* @ LINKAGE-BOOT
@ -85,7 +92,6 @@ public class ContractFileController {
private YozoUtils yozoUtils;
/**
*
*
@ -132,15 +138,6 @@ public class ContractFileController {
entitys.setContractId(entity.getId());
contract_item0Service.save(entitys);
}
@ -153,30 +150,88 @@ public class ContractFileController {
}
return ActionResult.success("创建成功");
}
/**
*
*
* @return
*/
@ApiOperation("模板下载")
@GetMapping("/templateDownload")
@GetMapping("/TemplateDownload")
public ActionResult<DownloadVO> TemplateDownload() {
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/file/DownloadModel?encryption=", userInfo.getId() + "#" + "合同档案信息" +
".xlsx" + "#" + "Temporary"));
} catch (Exception e) {
log.error("信息导出Excel错误:{}" ,e.getMessage());
log.error("信息导出Excel错误:" + e.getMessage());
}
return ActionResult.success(vo);
}
/**
* (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<ContractFileModel> personList = ExcelUtil.importExcel(temporary, 0, 1, ContractFileModel.class);
//预览数据
Map<String, Object> map = contractFileService.importPreview(personList);
return ActionResult.success(map);
}
/**
*
*
* @return
*/
@ApiOperation("导入数据")
@PostMapping("/ImportData")
public ActionResult ImportData(@RequestBody ContractFileModel data) {
List<ContractFileModel> dataList = JsonUtil.getJsonToList(data.getList(), ContractFileModel.class);
//导入数据
ContractfileImportVO result = contractFileService.importData(dataList);
return ActionResult.success(result);
}
/**
* Excel
*
@ -205,6 +260,7 @@ public class ContractFileController {
DownloadVO vo = this.creatModelExcel(configValueUtil.getTemporaryFilePath(), mapList, keys, userInfo);
return ActionResult.success(vo);
}
//导出表格
public DownloadVO creatModelExcel(String path, List<Map<String, Object>> list, String[] keys, UserInfo userInfo) {
DownloadVO vo = DownloadVO.builder().build();
@ -400,8 +456,6 @@ public class ContractFileController {
}
/**
*
*
@ -425,15 +479,6 @@ public class ContractFileController {
for (Contract_item0Entity entitys : Contract_item0List) {
entitys.setId(RandomUtil.uuId());
entitys.setContractId(entity.getId());
contract_item0Service.save(entitys);
@ -459,7 +504,6 @@ public class ContractFileController {
}
/**
*
*
@ -484,7 +528,6 @@ public class ContractFileController {
}
/**
*
*

@ -3,6 +3,7 @@
package jnpf.contractfile.model.contractfile;
import jnpf.permission.model.user.vo.UserExportVO;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
@ -131,4 +132,6 @@ public class ContractFileInfoVO{
/** 子表数据 **/
@JsonProperty("contract_item1List")
private List<Contract_item1Model> contract_item1List;
private List<ContractFileInfoVO> list;
}

@ -0,0 +1,48 @@
package jnpf.contractfile.model.contractfile;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.List;
/**
*
* @author Allen Pan
* @version V3.4.1
* @copyright
*
*/
@Data
public class ContractFileModel {
@Excel(name = "合同编码")
private String contractCode;
@Excel(name = "合同名称")
private String contractName;
@Excel(name = "对方合同号")
private String contractNo;
@Excel(name = "合同类型")
private String contractType;
@Excel(name = "合同分类")
private String classification;
@Excel(name = "申报日期")
private String declarationDate;
@Excel(name = "供应商/客户")
private String name;
@Excel(name = "数量")
private String num;
@Excel(name = "金额")
private String amount;
@Excel(name = "部门名称")
private String deptName;
@Excel(name = "备注")
private String remark;
@Excel(name = "录入人")
private String creatorusername;
@Excel(name = "合同状态")
private String status;
@Excel(name = "集团审批")
private String approval;
private List<ContractFileModel> list;
private String creatorTime;
}

@ -0,0 +1,36 @@
package jnpf.contractfile.model.contractfile;
import jnpf.contractfile.model.contractfile.ContractFileModel;
import lombok.Data;
import java.util.List;
/**
*
* @author Allen Pan
* @version V3.4.1
* @copyright
*
*/
@Data
public class ContractfileImportVO {
/**
*
*/
private int snum;
/**
*
*/
private int fnum;
/**
* (0, 1)
*/
private int resultType;
/**
*
*/
private List<ContractFileModel> failResult;
}

@ -1,10 +1,21 @@
package jnpf.contractfile.service;
import jnpf.base.ActionResult;
import jnpf.base.entity.BillRuleEntity;
import jnpf.contractfile.entity.Contract_item0Entity;
import jnpf.contractfile.entity.Contract_item1Entity;
import jnpf.contractfile.entity.ContractFileEntity;
import com.baomidou.mybatisplus.extension.service.IService;
import jnpf.contractfile.model.contractfile.ContractFileInfoVO;
import jnpf.contractfile.model.contractfile.ContractFileModel;
import jnpf.contractfile.model.contractfile.ContractFilePagination;
import jnpf.contractfile.model.contractfile.ContractfileImportVO;
import jnpf.exception.DataException;
import jnpf.model.EmployeeModel;
import jnpf.model.employee.EmployeeImportVO;
import jnpf.permission.model.user.vo.UserExportVO;
import jnpf.permission.model.user.vo.UserImportVO;
import java.util.*;
/**
*
@ -30,6 +41,22 @@ public interface ContractFileService extends IService<ContractFileEntity> {
boolean update( String id, ContractFileEntity entity);
/**
*
*
* @param personList
* @return
*/
Map<String, Object> importPreview(List<ContractFileModel> personList);
/**
*
*
* @param dt
*/
ContractfileImportVO importData(List<ContractFileModel> dt);
// 子表方法
List<Contract_item0Entity> GetContract_item0List(String id);
List<Contract_item1Entity> GetContract_item1List(String id);

@ -2,16 +2,23 @@ package jnpf.contractfile.service.impl;
import jnpf.contractfile.entity.*;
import jnpf.contractfile.mapper.ContractFileMapper;
import jnpf.contractfile.model.contractfile.ContractFileModel;
import jnpf.contractfile.model.contractfile.ContractfileImportVO;
import jnpf.contractfile.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.hutool.core.util.ObjectUtil;
import jnpf.entity.EmployeeEntity;
import jnpf.model.EmployeeModel;
import jnpf.model.employee.EmployeeImportVO;
import jnpf.permission.model.authorize.AuthorizeConditionModel;
import jnpf.contractfile.model.contractfile.ContractFilePagination;
import jnpf.permission.service.AuthorizeService;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
@ -21,10 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jnpf.util.*;
import java.util.*;
/**
*
* contractFile
* V3.2.0
* LINKAGE-BOOT
@ -49,8 +56,6 @@ public class ContractFileServiceImpl extends ServiceImpl<ContractFileMapper, Con
private Contract_item1Service contract_item1Service;
@Override
public List<ContractFileEntity> getList(ContractFilePagination contractFilePagination) {
String userId = userProvider.get().getUserId();
@ -148,6 +153,7 @@ public class ContractFileServiceImpl extends ServiceImpl<ContractFileMapper, Con
return contractFilePagination.setData(list, list.size());
}
}
@Override
public List<ContractFileEntity> getTypeList(ContractFilePagination contractFilePagination, String dataType) {
String userId = userProvider.get().getUserId();
@ -267,12 +273,135 @@ public class ContractFileServiceImpl extends ServiceImpl<ContractFileMapper, Con
entity.setId(id);
return this.updateById(entity);
}
@Override //预览
public Map<String, Object> importPreview(List<ContractFileModel> 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<>();
ContractFileModel model = personList.get(i);
dataRowMap.put("contractCode", model.getContractCode());
dataRowMap.put("contractName", model.getContractName());
dataRowMap.put("contractNo", model.getContractNo());
dataRowMap.put("contractType", model.getContractType());
dataRowMap.put("classification", model.getClassification());
dataRowMap.put("declarationDate", model.getDeclarationDate());
dataRowMap.put("name", model.getName());
dataRowMap.put("num", model.getNum());
dataRowMap.put("amount", model.getAmount());
dataRowMap.put("deptName", model.getDeptName());
dataRowMap.put("remark", model.getRemark());
dataRowMap.put("creatorusername", model.getCreatorusername());
dataRowMap.put("status", model.getStatus());
dataRowMap.put("approval", model.getApproval());
dataRow.add(dataRowMap);
}
for (int i = 1; i < 15; 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;
}
//导入
@Override
public ContractfileImportVO importData(List<ContractFileModel> dt) {
for (ContractFileModel model : dt) {
model.setCreatorTime(DateUtil.cstFormat(model.getCreatorTime()));
model.setNum(DateUtil.cstFormat(model.getNum()));
if (model.getContractType() != null) {
if (model.getContractType().equals("采购合同")) {
model.setContractType("0");
} else if (model.getContractType().equals("销售合同")) {
model.setContractType("1");
}
}
if (model.getClassification() != null) {
if (model.getClassification().equals("采购类")) {
model.setClassification("0");
} else if (model.getClassification().equals("销售类")) {
model.setClassification("1");
}
}
if (model.getStatus() != null) {
if (model.getStatus().equals("合同进行中")) {
model.setStatus("0");
} else if (model.getStatus().equals("合同审批中")) {
model.setStatus("1");
} else if (model.getStatus().equals("合同审批结束")) {
model.setStatus("2");
}
}
}
List<ContractFileEntity> entitys = JsonUtil.getJsonToList(dt, ContractFileEntity.class);
//记录成功了几条
int sum = 0;
//记录第几条失败
int num = 0;
List<ContractFileEntity> errList = new ArrayList<>();
for (ContractFileEntity entity : entitys) {
entity.setId(RandomUtil.uuId());
entity.setCreatoruserid(userProvider.get().getUserId());
entity.setCreatortime(new Date());
try {
this.baseMapper.insert(entity);
sum++;
} catch (Exception e) {
errList.add(entity);
num++;
log.error("导入第" + (num + 1) + "条数据失败");
}
}
ContractfileImportVO vo = new ContractfileImportVO();
vo.setSnum(sum);
vo.setFnum(num);
if (vo.getFnum() > 0) {
vo.setResultType(1);
vo.setFailResult(JsonUtil.getJsonToList(errList, ContractFileModel.class));
return vo;
} else {
vo.setResultType(0);
return vo;
}
}
@Override
public void delete(ContractFileEntity entity) {
if (entity != null) {
this.removeById(entity.getId());
}
}
//子表方法
@Override
public List<Contract_item0Entity> GetContract_item0List(String id) {
@ -280,6 +409,7 @@ public class ContractFileServiceImpl extends ServiceImpl<ContractFileMapper, Con
queryWrapper.lambda().eq(Contract_item0Entity::getContractId, id);
return contract_item0Service.list(queryWrapper);
}
@Override
public List<Contract_item1Entity> GetContract_item1List(String id) {
QueryWrapper<Contract_item1Entity> queryWrapper = new QueryWrapper<>();
@ -290,4 +420,42 @@ public class ContractFileServiceImpl extends ServiceImpl<ContractFileMapper, Con
//列表子表数据方法
private String getKey(String key) {
Map<String, String> map = new HashMap<>();
map.put("工号", "F_EnCode");
map.put("姓名", "F_FullName");
map.put("性别", "F_Gender");
map.put("部门", "F_DepartmentName");
map.put("岗位", "F_PositionName");
map.put("用工性质", "F_WorkingNature");
map.put("身份证号", "F_IDNumber");
map.put("联系电话", "F_Telephone");
map.put("出生年月", "F_Birthday");
map.put("参加工作", "F_AttendWorkTime");
map.put("最高学历", "F_Education");
map.put("所学专业", "F_Major");
map.put("毕业院校", "F_GraduationAcademy");
map.put("毕业时间", "F_GraduationTime");
return map.get(key);
}
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, "数量");
map.put(9, "金额");
map.put(10, "部门名称");
map.put(11, "备注");
map.put(12, "录入人");
map.put(13, "单据状态");
map.put(14, "集团审批");
return map.get(key);
}
}

@ -237,6 +237,7 @@ public class BillRuleServiceImpl extends ServiceImpl<BillRuleMapper, BillRuleEnt
return ActionResult.fail(MsgCode.EXIST002.get());
}
try {
this.save(entity);
} catch (Exception e) {
throw new DataException(MsgCode.IMP003.get());

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

@ -0,0 +1,264 @@
<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">
<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/example/ContractFile/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="contractCode" label="合同编码" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.contractCode" />
</template>
</el-table-column>
<el-table-column prop="contractName" label="合同名称" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.contractName" />
</template>
</el-table-column>
<el-table-column prop="contractNo" label="对方合同号" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.contractNo" />
</template>
</el-table-column>
<el-table-column prop="contractType" label="合同类型" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.contractType" />
</template>
</el-table-column>
<el-table-column prop="classification" label="合同分类" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.classification" />
</template>
</el-table-column>
<el-table-column prop="declarationDate" label="申报日期" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.declarationDate" />
</template>
</el-table-column>
<el-table-column prop="name" label="供应商/客户" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.name" />
</template>
</el-table-column>
<el-table-column prop="num" label="数量" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.num" />
</template>
</el-table-column>
<el-table-column prop="amount" label="金额" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.amount" />
</template>
</el-table-column>
<el-table-column prop="deptName" label="部门名称" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.deptName" />
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.remark" />
</template>
</el-table-column>
<el-table-column prop="creatorusername" label="录入人" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.creatorusername" />
</template>
</el-table-column>
<el-table-column prop="status" label="合同状态" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.status" />
</template>
</el-table-column>
<el-table-column prop="approval" label="集团审批" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.approval" />
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" 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">您已成功导入{{result.snum}}条数据</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="contractCode" label="合同编码" width="100" />
<el-table-column prop="contractName" label="合同名称" width="100" />
<el-table-column prop="contractNo" label="对方合同号" width="80" />
<el-table-column prop="contractType" label="合同类型 0采购合同1销售合同" width="120" />
<el-table-column prop="classification" label="合同分类 0采购类1销售类" width="120" />
<el-table-column prop="declarationDate" label="申报日期" width="100" />
<el-table-column prop="name" label="供应商/客户" width="150" />
<el-table-column prop="num" label="数量" width="100" />
<el-table-column prop="amount" label="金额" width="100" />
<el-table-column prop="deptName" label="部门名称" width="100" />
<el-table-column prop="remark" label="备注" width="100" />
<el-table-column prop="creatorusername" label="录入人" width="120" />
<el-table-column prop="status" label="单据状态" width="150" />
<el-table-column prop="approval" label="集团审批" width="100" />
</JNPF-table>
</div>
</div>
<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/contractfile'
export default {
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
ImportData({ list: this.list }).then(res => {
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
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>

@ -31,8 +31,10 @@
<!-- </el-button>-->
<el-button type="text" icon="el-icon-download" @click="exportData()">
</el-button>
<!-- <el-button type="text" icon="el-icon-delete" @click="handleBatchRemoveDel()">-->
<!-- </el-button>-->
<el-button type="text" icon="el-icon-upload2" @click="uploadForm"></el-button>
</div>
<div class="JNPF-common-head-right">
<el-tooltip effect="dark" content="刷新" placement="top">
@ -54,7 +56,13 @@
{{ scope.row.contractType | dynamicText(contractTypeOptions) }}
</template>
</el-table-column>
<el-table-column prop="classification" label="合同分类 " width="120" align="center" sortable/>
<el-table-column prop="classification" label="合同分类 " width="120" align="center" sortable>
<template slot-scope="scope">
{{ scope.row.classification | dynamicText(classificationOptions) }}
</template>
</el-table-column>
<el-table-column prop="declarationDate" label="申报日期" width="120" align="center" sortable/>
<el-table-column prop="name" label="供应商/客户名" width="200" align="center" sortable/>
<el-table-column prop="num" label="数量" width="120" align="center" sortable/>
@ -98,10 +106,15 @@
<JNPF-Form v-if="formVisible" ref="JNPFForm" @refresh="refresh"/>
<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>
<script>
import ImportForm from './ImportForm'
import request from '@/utils/request'
import {
getDictionaryDataSelector
@ -113,11 +126,14 @@
} from '@/api/systemData/dataInterface'
import Detail from './Detail'
export default {
components: {
JNPFForm,
ExportBox,
Detail
Detail,
ImportForm
},
data() {
return {
@ -142,6 +158,9 @@
sidx: ''
},
formVisible: false,
importFormVisible: false,
exportBoxVisible: false,
columnList: [{
prop: 'contractCode',
@ -202,10 +221,10 @@
],
contractTypeOptions: [{
'fullName': '采购合同',
'id': '1'
'id': '0'
}, {
'fullName': '销售合同',
'id': '2'
'id': '1'
},
{
'fullName': '租赁合同',
@ -225,7 +244,21 @@
statusOptions: [{
"fullName": "进行中",
"id": "1"
"id": "0",
},{
"fullName": "审批中",
"id": "1",
},{
"fullName": "审批结束",
"id": "2"
}],
classificationOptions: [{
"fullName": "采购类",
"id": "0",
},{
"fullName": "销售类",
"id": "1",
}],
contractTypeProps: {
@ -381,6 +414,13 @@
this.query[key] = undefined
}
this.search()
},
uploadForm() {
this.importFormVisible = true
this.$nextTick(() => {
this.$refs.importForm.init()
})
}
}
}

@ -21,9 +21,11 @@
</el-row>
<div class="JNPF-common-layout-main JNPF-flex-main">
<div class="JNPF-common-head">
<topOpts @add="addOrUpdateHandle()">
<upload-btn url="/api/system/BillRule/Action/Import" @on-success="initData" />
</topOpts>
<div class="JNPF-common-head-right">
<el-tooltip effect="dark" :content="$t('common.refresh')" placement="top">
<el-link icon="icon-ym icon-ym-Refresh JNPF-common-head-icon" :underline="false"
@ -31,6 +33,7 @@
</el-tooltip>
</div>
</div>
<JNPF-table v-loading="listLoading" :data="tableList">
<el-table-column prop="fullName" label="业务名称" min-width="200" />
<el-table-column prop="enCode" label="业务编码" width="200" />

Loading…
Cancel
Save