Commit 1089c7cb authored by 吴卿华's avatar 吴卿华

Merge remote-tracking branch 'origin/master'

parents 30f81adc 8ffbd43c
......@@ -101,4 +101,22 @@ public class TTradeProjectController extends BaseController
{
return toAjax(tTradeProjectService.deleteTTradeProjectByIds(tradeIds));
}
/**
* 交易结算
* @param tTradeProject
* @return
*/
@PostMapping("/settlementTrade")
public AjaxResult settlementTrade(@RequestBody TTradeProject tTradeProject){
return toAjax(tTradeProjectService.settlementTrade(tTradeProject));
}
@GetMapping("/getIncomeOrPayableList")
public TableDataInfo getIncomeOrPayableList(TTradeProject tTradeProject)
{
startPage();
List<TTradeProject> list = tTradeProjectService.getIncomeOrPayableList(tTradeProject);
return getDataTable(list);
}
}
......@@ -16,6 +16,7 @@ import com.zehong.system.service.ITTransactionProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
......@@ -82,6 +83,23 @@ public class TTransactionProjectController extends BaseController
return util.exportExcel(list, "交易项目数据");
}
@Log(title = "交易项目维护", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
{
ExcelUtil<TTransactionProject> util = new ExcelUtil<TTransactionProject>(TTransactionProject.class);
List<TTransactionProject> transactionList = util.importExcel(file.getInputStream());
String message = tTransactionProjectService.importTransaction(transactionList, updateSupport);
return AjaxResult.success(message);
}
@GetMapping("/importTemplate")
public AjaxResult importTemplate()
{
ExcelUtil<TTransactionProject> util = new ExcelUtil<TTransactionProject>(TTransactionProject.class);
return util.importTemplateExcel("交易项目数据");
}
/**
* 获取交易项目详细信息
*/
......
......@@ -131,6 +131,16 @@ public class TTradeProject extends BaseEntity
private String tradeTransactorName;
public String getProjectName() {
return projectName;
}
public void setProjectName(String projectName) {
this.projectName = projectName;
}
private String projectName;
/**操作类型*/
private List<String> operators = new ArrayList<>();
......
......@@ -32,7 +32,7 @@ public class TTransactionProject extends BaseEntity
private String context;
/** 定价类型:1.单价 2.议价 */
@Excel(name = "定价类型:1.单价 2.议价")
@Excel(name = "定价类型:1定价 2议价")
private String priceType;
/** 单价 */
......@@ -40,14 +40,13 @@ public class TTransactionProject extends BaseEntity
private BigDecimal price;
/** 部门 */
@Excel(name = "部门")
@Excel(name = "部门:103泽宏云研发部,104泽宏云技术部,105泽宏云销售部,200核算部,201综合管理部,202销售服务部")
private Long deptId;
/**部门名称*/
private String deptName;
/** 是否删除:0否,1是 */
@Excel(name = "是否删除:0否,1是")
private String isDel;
public void setTransactionProjectId(Long transactionProjectId)
......
......@@ -58,4 +58,18 @@ public interface TTradeProjectMapper
* @return 结果
*/
public int deleteTTradeProjectByIds(Long[] tradeIds);
/**
* 获取进货交易尾款
* @param tradeDeptId 进货部门id
* @return
*/
List<TTradeProject> getTradePendingPaymentInfo(Long tradeDeptId);
/**
* 查询应收、应付项目列表
* @param tTradeProject
* @return
*/
public List<TTradeProject> getIncomeOrPayableList(TTradeProject tTradeProject);
}
......@@ -19,6 +19,14 @@ public interface TTransactionProjectMapper
*/
public TTransactionProject selectTTransactionProjectById(Long transactionProjectId);
/**
* 查询交易项目
*
* @param transactionProjectName 交易项目名称
* @return 交易项目
*/
public TTransactionProject selectTransactionProjectByName(String transactionProjectName);
/**
* 查询交易项目列表
*
......
......@@ -65,4 +65,12 @@ public interface ITTradeProjectService
* @return 结果
*/
public int deleteTTradeProjectById(Long tradeId);
/**
* 交易结算
* @param tTradeProject
* @return
*/
int settlementTrade(TTradeProject tTradeProject);
public List<TTradeProject> getIncomeOrPayableList(TTradeProject tTradeProject);
}
......@@ -58,4 +58,14 @@ public interface ITTransactionProjectService
* @return 结果
*/
public int deleteTTransactionProjectById(Long transactionProjectId);
/**
* 导入数据
*
* @param transactionList 数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @return 结果
*/
public String importTransaction(List<TTransactionProject> transactionList, Boolean isUpdateSupport);
}
......@@ -7,14 +7,17 @@ import com.zehong.common.utils.SecurityUtils;
import com.zehong.system.domain.TTradeProject;
import com.zehong.system.mapper.TTradeProjectMapper;
import com.zehong.system.service.ITTradeProjectService;
import com.zehong.system.service.impl.tradeRoles.*;
import com.zehong.system.service.impl.tradeRoles.TradeRoles;
import com.zehong.system.service.impl.tradeRoles.roles.DeptLeader;
import com.zehong.system.service.impl.tradeRoles.roles.DoubleRoles;
import com.zehong.system.service.impl.tradeRoles.roles.OtherRoles;
import com.zehong.system.service.impl.tradeRoles.roles.Transactor;
import com.zehong.system.service.impl.tradeSettlement.SettlementTrade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
......@@ -30,6 +33,9 @@ public class TTradeProjectServiceImpl implements ITTradeProjectService
@Autowired
private TTradeProjectMapper tTradeProjectMapper;
@Resource
private SettlementTrade settlementTrade;
/**
* 查询交易项目
*
......@@ -120,18 +126,8 @@ public class TTradeProjectServiceImpl implements ITTradeProjectService
public int updateTTradeProject(TTradeProject tTradeProject)
{
tTradeProject.setUpdateTime(DateUtils.getNowDate());
//如果卖方部门长审批通过,则需要账户资金划拨
//暂时未判断账户可用金额等信息,仅第一版演示临时用 lizhichao-0612
if ("3".equals(tTradeProject.getTradeStatus())) {
tTradeProject.setPendingPayment(tTradeProject.getDealPrice());
}
return tTradeProjectMapper.updateTTradeProject(tTradeProject);
}
//资金划拨
private int cumputeAccount(TTradeProject tTradeProject){
return 1;
}
/**
* 批量删除交易项目
*
......@@ -155,4 +151,26 @@ public class TTradeProjectServiceImpl implements ITTradeProjectService
{
return tTradeProjectMapper.deleteTTradeProjectById(tradeId);
}
/**
* 交易结算
* @param tTradeProject
* @return
*/
@Transactional(rollbackFor = Exception.class)
public int settlementTrade(TTradeProject tTradeProject){
TTradeProject tradeInfo = tTradeProjectMapper.selectTTradeProjectById(tTradeProject.getTradeId());
//交易结算
settlementTrade.settleAbleAmount(tradeInfo);
tradeInfo.setTradeStatus(tTradeProject.getTradeStatus());
tradeInfo.setApplyDeptManagerId(tTradeProject.getApplyDeptManagerId());
return tTradeProjectMapper.updateTTradeProject(tradeInfo);
}
@Override
public List<TTradeProject> getIncomeOrPayableList(TTradeProject tTradeProject) {
return tTradeProjectMapper.getIncomeOrPayableList(tTradeProject);
}
}
package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.exception.CustomException;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.service.ISysConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TTransactionProjectMapper;
......@@ -17,9 +25,13 @@ import com.zehong.system.service.ITTransactionProjectService;
@Service
public class TTransactionProjectServiceImpl implements ITTransactionProjectService
{
private static final Logger log = LoggerFactory.getLogger(TTransactionProjectServiceImpl.class);
@Autowired
private TTransactionProjectMapper tTransactionProjectMapper;
@Autowired
private ISysConfigService configService;
/**
* 查询交易项目
*
......@@ -93,4 +105,67 @@ public class TTransactionProjectServiceImpl implements ITTransactionProjectServi
{
return tTransactionProjectMapper.deleteTTransactionProjectById(transactionProjectId);
}
/**
* 导入数据
*
* @param transactionList 数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @return 结果
*/
@Override
public String importTransaction(List<TTransactionProject> transactionList, Boolean isUpdateSupport)
{
if (StringUtils.isNull(transactionList) || transactionList.size() == 0)
{
throw new CustomException("导入数据不能为空!");
}
int successNum = 0;
int failureNum = 0;
StringBuilder successMsg = new StringBuilder();
StringBuilder failureMsg = new StringBuilder();
for (TTransactionProject transaction : transactionList)
{
try
{
// 验证是否存在这个用户
TTransactionProject project = tTransactionProjectMapper.selectTransactionProjectByName(transaction.getTransactionProjectName());
if (StringUtils.isNull(project))
{
this.insertTTransactionProject(transaction);
successNum++;
successMsg.append("<br/>" + successNum + "、交易项目 " + transaction.getTransactionProjectName() + " 导入成功");
}
else if (isUpdateSupport)
{
transaction.setTransactionProjectId(project.getTransactionProjectId());
this.updateTTransactionProject(transaction);
successNum++;
successMsg.append("<br/>" + successNum + "、交易项目 " + transaction.getTransactionProjectName() + " 更新成功");
}
else
{
failureNum++;
failureMsg.append("<br/>" + failureNum + "、交易项目 " + transaction.getTransactionProjectName() + " 已存在");
}
}
catch (Exception e)
{
failureNum++;
String msg = "<br/>" + failureNum + "、交易项目 " + transaction.getTransactionProjectName() + " 导入失败:";
failureMsg.append(msg + e.getMessage());
log.error(msg, e);
}
}
if (failureNum > 0)
{
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
throw new CustomException(failureMsg.toString());
}
else
{
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
}
return successMsg.toString();
}
}
package com.zehong.system.service.impl.tradeSettlement;
import com.zehong.system.domain.TAccount;
import com.zehong.system.domain.TCashOperate;
import com.zehong.system.domain.TTradeProject;
import com.zehong.system.mapper.TAccountMapper;
import com.zehong.system.mapper.TCashOperateMapper;
import com.zehong.system.mapper.TTradeProjectMapper;
import io.jsonwebtoken.lang.Collections;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @author geng
* 交易结算
*/
@Component
public class SettlementTrade {
private TTradeProject tradeProject;
@Resource
private TAccountMapper tAccountMapper;
@Resource
private TTradeProjectMapper tTradeProjectMapper;
@Resource
private TCashOperateMapper cashOperateMapper;
/**
* 可用账户结算
*/
public void settleAbleAmount(TTradeProject tradeProject){
this.tradeProject = tradeProject;
//买方结算
settleBuyerAbleAmount();
//卖方结算
settleSellerAbleAmount();
}
/**
* 买方结算
*/
private void settleBuyerAbleAmount() {
TAccount account = getAccountInfo(this.tradeProject.getTradeDeptId());
//判断买方可用额度是否为0
if(account.getAbleAmount().compareTo(BigDecimal.ZERO) == 0){
this.tradeProject.setPendingPayment(this.tradeProject.getDealPrice());
return;
}
//买方可用额度为0,计算尾款
BigDecimal pendingPayment = account.getAbleAmount().compareTo(tradeProject.getDealPrice()) == 1 ?
new BigDecimal("0") :
this.tradeProject.getDealPrice().subtract(account.getAbleAmount());
this.tradeProject.setPendingPayment(pendingPayment);
//买方可用额度计算
BigDecimal payment = pendingPayment.compareTo(BigDecimal.ZERO) == 0 ?
this.tradeProject.getDealPrice().negate() :
account.getAbleAmount().negate();
updateAccount(account,payment);
}
/**
* 卖方结算
*/
private void settleSellerAbleAmount() {
TAccount account = getAccountInfo(this.tradeProject.getApplyDeptId());
//进账
BigDecimal incomeAmount = this.tradeProject.getDealPrice().subtract(this.tradeProject.getPendingPayment());
//判断是否有进账
if(incomeAmount.compareTo(BigDecimal.ZERO) == 1 && account.getAbleAmount().compareTo(BigDecimal.ZERO) == 0){
//结算本部尾款
List<TTradeProject> pendingPaymentInfo = tTradeProjectMapper.getTradePendingPaymentInfo(this.tradeProject.getApplyDeptId());
for(TTradeProject project : pendingPaymentInfo){
if(incomeAmount.compareTo(BigDecimal.ZERO) == 0){
return;
}
BigDecimal amount = updatePendingPayment(incomeAmount,project);
//重新计算进账金额
incomeAmount = incomeAmount.subtract(amount);
}
}
//更新可用额度
updateAccount(account,incomeAmount);
}
/**
* 获取账户信息
* @param deptId
* @return
*/
private TAccount getAccountInfo(Long deptId){
TAccount tAccount = new TAccount();
tAccount.setDeptId(deptId);
List<TAccount> accounts = tAccountMapper.selectTAccountList(tAccount);
assert !Collections.isEmpty(accounts) : "部门资金账户不能为空,部门id:" + tradeProject.getApplyDeptId();
return accounts.get(0);
}
/**
* 更新账户可用金额
* @param tAccount 账户信息
* @param amount 账户变动金额
*/
private void updateAccount(TAccount tAccount,BigDecimal amount){
if(amount.compareTo(BigDecimal.ZERO) == 0) return;
tAccount.setAbleAmount(tAccount.getAbleAmount().add(amount));
tAccountMapper.updateTAccount(tAccount);
//更新资金变动日志
TCashOperate operate = OperatorParam(tAccount.getDeptId(),amount,this.tradeProject.getReceiptNum());
operate.setOperateType(amount.compareTo(BigDecimal.ZERO) == 1 ? "1" : "2");
cashOperateMapper.insertTCashOperate(operate);
}
/**
* 更新尾款信息
* @param incomeAmount 进账金额
* @param project 交易项目
*/
private BigDecimal updatePendingPayment(BigDecimal incomeAmount,TTradeProject project){
//资金变动金额
BigDecimal amount = incomeAmount.compareTo(project.getPendingPayment()) == 1 ? project.getPendingPayment() : incomeAmount;
//尾款
BigDecimal pendingPayment = incomeAmount.compareTo(project.getPendingPayment()) == -1 ? project.getPendingPayment().subtract(incomeAmount) : new BigDecimal("0");
project.setPendingPayment(pendingPayment);
tTradeProjectMapper.updateTTradeProject(project);
//更新资金变动日志
TCashOperate operate = OperatorParam(project.getTradeDeptId(),amount,project.getReceiptNum());
operate.setOperateType("3");
cashOperateMapper.insertTCashOperate(operate);
return amount;
}
/**
*
* @param deptId 部门id
* @param amount 变动金额
* @param receiptNum 单据号
* @return
*/
private TCashOperate OperatorParam (Long deptId,BigDecimal amount,String receiptNum){
TCashOperate operate = new TCashOperate();
operate.setOperateDeptId(deptId);
operate.setOperateAmount(amount.compareTo(BigDecimal.ZERO) == 1?amount:amount.abs());
operate.setOperateTime(new Date());
operate.setRelationDoc(receiptNum);
return operate;
}
}
......@@ -8,6 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="tradeId" column="trade_id" />
<result property="receiptNum" column="receipt_num" />
<result property="relationTransactionProjectId" column="relation_transaction_project_id" />
<result property="projectName" column="project_name" />
<result property="applyId" column="apply_id" />
<result property="applyDeptId" column="apply_dept_id" />
<result property="applyDeptManagerId" column="apply_dept_manager_id" />
......@@ -214,4 +215,52 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{tradeId}
</foreach>
</delete>
<select id="getTradePendingPaymentInfo" parameterType="Long" resultMap="TTradeProjectResult">
<include refid="selectTTradeProjectVo"/>
t_trade_project
WHERE trade_dept_id = #{tradeDeptId}
AND trade_status = '3'
AND pending_payment > 0
</select>
<select id="getIncomeOrPayableList" parameterType="TTradeProject" resultMap="TTradeProjectResult">
SELECT
trade_id,
receipt_num,
relation_transaction_project_id,
apply_id,
apply_dept_id,
apply_dept_manager_id,
(select transaction_project_name from t_transaction_project where transaction_project_id=relation_transaction_project_id) project_name,
trade_transactor,
trade_dept_id,
trade_price,
trade_count,
trade_total,
trade_score,
trade_dept_manager_id,
settlement_time,
deal_price,
pending_payment,
attachment_url,
trade_status,
create_time,
update_time,
is_del,
remark,
deal_remark,
(SELECT nick_name FROM sys_user WHERE user_id = trade_transactor) AS trade_transactor_name,
(SELECT nick_name FROM sys_user WHERE user_id = apply_id) AS apply_name,
(SELECT dept_name FROM sys_dept WHERE dept_id = apply_dept_id) AS apply_dept_name,
(SELECT dept_name FROM sys_dept WHERE dept_id = trade_dept_id) AS trade_dept_name
FROM
t_trade_project
<where>
trade_status =3 and pending_payment>0
<if test="applyDeptId != null"> and apply_dept_id = #{applyDeptId}</if>
<if test="tradeTransactor != null"> and trade_transactor = #{tradeTransactor}</if>
<if test="tradeDeptId != null"> and trade_dept_id = #{tradeDeptId}</if>
</where>
order by create_time desc
</select>
</mapper>
\ No newline at end of file
......@@ -40,6 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTTransactionProjectVo"/>
where transaction_project_id = #{transactionProjectId}
</select>
<select id="selectTransactionProjectByName" parameterType="String" resultMap="TTransactionProjectResult">
<include refid="selectTTransactionProjectVo"/>
where transaction_project_name = #{transactionProjectName}
</select>
<insert id="insertTTransactionProject" parameterType="TTransactionProject" useGeneratedKeys="true" keyProperty="transactionProjectId">
insert into t_transaction_project
......@@ -76,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="transactionItemName != null">transaction_item_name = #{transactionItemName},</if>
<if test="context != null">context = #{context},</if>
<if test="priceType != null">price_type = #{priceType},</if>
<if test="price != null">price = #{price},</if>
price = #{price},
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
......
......@@ -60,3 +60,11 @@ export function exportProject(query) {
params: query
})
}
// 下载导入模板
export function importTemplate() {
return request({
url: '/transaction/project/importTemplate',
method: 'get'
})
}
......@@ -60,3 +60,12 @@ export function exportProject(query) {
params: query
})
}
//交易结算
export function settlementTrade(data) {
return request({
url: '/trade/project/settlementTrade',
method: 'post',
data: data
})
}
......@@ -13,13 +13,15 @@
<el-table-column
label="交易项目"
align="center"
prop="a"
prop="projectName"
:formatter="formatter"
/>
<el-table-column label="卖方" align="center" prop="tradeTransactorName" />
<el-table-column label="卖方部门" align="center" prop="applyDeptName" />
<el-table-column label="申请人" align="center" prop="applyName" />
<el-table-column label="买方" align="center" prop="applyDeptName" />
<el-table-column label="买方经办人" align="center" prop="tradeDeptName" />
<el-table-column label="申请时间" align="center" prop="createTime" />
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="买方部门" align="center" prop="tradeDeptName" />
<el-table-column label="买方经办人" align="center" prop="tradeTransactorName" />
<template v-if="or === 'income'">
<el-table-column
label="应收金额"
......
......@@ -204,8 +204,9 @@
/>
<el-table-column label="操作类型" align="center" prop="operateType">
<template slot-scope="scope">
<span v-if="scope.row.operateType == '1'">借贷</span>
<span v-if="scope.row.operateType == '2'">借支</span>
<span v-if="scope.row.operateType == '1'">收入</span>
<span v-if="scope.row.operateType == '2'">支出</span>
<span v-if="scope.row.operateType == '3'">尾款扣除</span>
</template>
</el-table-column>
<el-table-column label="金额" align="center" prop="operateAmount" />
......
......@@ -47,6 +47,7 @@
<script>
import CommonInfo from "./CommonInfo";
import { settlementTrade } from "@/api/transaction/tradeProject.js";
export default {
name: "approval",
props:{
......@@ -79,7 +80,7 @@
return false;
},
submitSuggestion(){
return {tradeId:this.tradeData.tradeId,tradeStatus:this.tradeStatus,dealPrice:this.tradeData.dealPrice,applyDeptManagerId:this.$store.state.user.userId};
return {tradeId:this.tradeData.tradeId,tradeStatus:this.tradeStatus,applyDeptManagerId:this.$store.state.user.userId};
}
}
}
......
......@@ -12,7 +12,7 @@
</template>
<script>
import { getProject, updateProject } from "@/api/transaction/tradeProject.js";
import { getProject, updateProject, settlementTrade } from "@/api/transaction/tradeProject.js";
import tradeDetail from "./TradeDetail";
import evaluate from "./Evaluate";
import confirm from "./Confirm";
......@@ -75,6 +75,18 @@
if(this.$refs.currentCom.checkParam()){
return;
}
if(this.operatorName == "approval"){
settlementTrade(this.$refs.currentCom.submitSuggestion()).then(res =>{
if(res.code == 200){
this.open = false;
this.$emit("getList");
this.$message.success("复核成功!");
}else{
this.$message.success("复核失败!");
}
})
return;
}
let that = this;
updateProject(this.$refs.currentCom.submitSuggestion()).then(res =>{
if(res.code == 200){
......
......@@ -56,6 +56,16 @@
v-hasPermi="['system:project:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-upload2"
size="mini"
@click="handleImport"
v-hasPermi="['system:user:import']"
>导入</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
......@@ -77,7 +87,7 @@
<el-table-column label="交易类型" align="center" prop="priceType">
<template slot-scope="scope">
<span v-if="scope.row.priceType == '1'">定价</span>
<span v-if="scope.row.priceType == '2'"></span>
<span v-if="scope.row.priceType == '2'"></span>
</template>
</el-table-column>
<el-table-column label="单价" align="center" prop="price">
......@@ -154,11 +164,43 @@
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
<!-- 导入对话框 -->
<el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
<el-upload
ref="upload"
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据
<el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
</div>
<div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listProject, getProject, delProject, addProject, updateProject, exportProject } from "@/api/transaction/project";
import { listProject, getProject, delProject, addProject, updateProject, exportProject, importTemplate } from "@/api/transaction/project";
import { getToken } from "@/utils/auth";
import { treeselect } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
......@@ -189,6 +231,21 @@ export default {
title: "",
// 是否显示弹出层
open: false,
// 导入参数
upload: {
// 是否显示弹出层(导入)
open: false,
// 弹出层标题(导入)
title: "",
// 是否禁用上传
isUploading: false,
// 是否更新已经存在的数据
updateSupport: 0,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/transaction/project/importData"
},
// 查询参数
queryParams: {
pageNum: 1,
......@@ -299,6 +356,33 @@ export default {
this.open = true;
this.title = "添加交易项目";
},
/** 导入按钮操作 */
handleImport() {
this.upload.title = "交易项目导入";
this.upload.open = true;
},
/** 下载模板操作 */
importTemplate() {
importTemplate().then(response => {
this.download(response.msg);
});
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.upload.isUploading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
this.upload.open = false;
this.upload.isUploading = false;
this.$refs.upload.clearFiles();
this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
this.getList();
},
// 提交上传文件
submitFileForm() {
this.$refs.upload.submit();
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment