Commit 836b1fa9 authored by 耿迪迪's avatar 耿迪迪
parents 6a992956 e038652e
...@@ -16,6 +16,7 @@ import com.zehong.system.service.ITTransactionProjectService; ...@@ -16,6 +16,7 @@ import com.zehong.system.service.ITTransactionProjectService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
...@@ -82,6 +83,23 @@ public class TTransactionProjectController extends BaseController ...@@ -82,6 +83,23 @@ public class TTransactionProjectController extends BaseController
return util.exportExcel(list, "交易项目数据"); 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("交易项目数据");
}
/** /**
* 获取交易项目详细信息 * 获取交易项目详细信息
*/ */
......
...@@ -32,7 +32,7 @@ public class TTransactionProject extends BaseEntity ...@@ -32,7 +32,7 @@ public class TTransactionProject extends BaseEntity
private String context; private String context;
/** 定价类型:1.单价 2.议价 */ /** 定价类型:1.单价 2.议价 */
@Excel(name = "定价类型:1.单价 2.议价") @Excel(name = "定价类型:1定价 2议价")
private String priceType; private String priceType;
/** 单价 */ /** 单价 */
...@@ -40,14 +40,13 @@ public class TTransactionProject extends BaseEntity ...@@ -40,14 +40,13 @@ public class TTransactionProject extends BaseEntity
private BigDecimal price; private BigDecimal price;
/** 部门 */ /** 部门 */
@Excel(name = "部门") @Excel(name = "部门:103泽宏云研发部,104泽宏云技术部,105泽宏云销售部,200核算部,201综合管理部,202销售服务部")
private Long deptId; private Long deptId;
/**部门名称*/ /**部门名称*/
private String deptName; private String deptName;
/** 是否删除:0否,1是 */ /** 是否删除:0否,1是 */
@Excel(name = "是否删除:0否,1是")
private String isDel; private String isDel;
public void setTransactionProjectId(Long transactionProjectId) public void setTransactionProjectId(Long transactionProjectId)
......
...@@ -19,6 +19,14 @@ public interface TTransactionProjectMapper ...@@ -19,6 +19,14 @@ public interface TTransactionProjectMapper
*/ */
public TTransactionProject selectTTransactionProjectById(Long transactionProjectId); public TTransactionProject selectTTransactionProjectById(Long transactionProjectId);
/**
* 查询交易项目
*
* @param transactionProjectName 交易项目名称
* @return 交易项目
*/
public TTransactionProject selectTransactionProjectByName(String transactionProjectName);
/** /**
* 查询交易项目列表 * 查询交易项目列表
* *
......
...@@ -58,4 +58,14 @@ public interface ITTransactionProjectService ...@@ -58,4 +58,14 @@ public interface ITTransactionProjectService
* @return 结果 * @return 结果
*/ */
public int deleteTTransactionProjectById(Long transactionProjectId); public int deleteTTransactionProjectById(Long transactionProjectId);
/**
* 导入数据
*
* @param transactionList 数据列表
* @param isUpdateSupport 是否更新支持,如果已存在,则进行更新数据
* @return 结果
*/
public String importTransaction(List<TTransactionProject> transactionList, Boolean isUpdateSupport);
} }
package com.zehong.system.service.impl; package com.zehong.system.service.impl;
import java.util.List; 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.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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TTransactionProjectMapper; import com.zehong.system.mapper.TTransactionProjectMapper;
...@@ -17,9 +25,13 @@ import com.zehong.system.service.ITTransactionProjectService; ...@@ -17,9 +25,13 @@ import com.zehong.system.service.ITTransactionProjectService;
@Service @Service
public class TTransactionProjectServiceImpl implements ITTransactionProjectService public class TTransactionProjectServiceImpl implements ITTransactionProjectService
{ {
private static final Logger log = LoggerFactory.getLogger(TTransactionProjectServiceImpl.class);
@Autowired @Autowired
private TTransactionProjectMapper tTransactionProjectMapper; private TTransactionProjectMapper tTransactionProjectMapper;
@Autowired
private ISysConfigService configService;
/** /**
* 查询交易项目 * 查询交易项目
* *
...@@ -93,4 +105,67 @@ public class TTransactionProjectServiceImpl implements ITTransactionProjectServi ...@@ -93,4 +105,67 @@ public class TTransactionProjectServiceImpl implements ITTransactionProjectServi
{ {
return tTransactionProjectMapper.deleteTTransactionProjectById(transactionProjectId); 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();
}
} }
...@@ -40,6 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -40,6 +40,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectTTransactionProjectVo"/> <include refid="selectTTransactionProjectVo"/>
where transaction_project_id = #{transactionProjectId} where transaction_project_id = #{transactionProjectId}
</select> </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 id="insertTTransactionProject" parameterType="TTransactionProject" useGeneratedKeys="true" keyProperty="transactionProjectId">
insert into t_transaction_project insert into t_transaction_project
...@@ -76,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -76,7 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="transactionItemName != null">transaction_item_name = #{transactionItemName},</if> <if test="transactionItemName != null">transaction_item_name = #{transactionItemName},</if>
<if test="context != null">context = #{context},</if> <if test="context != null">context = #{context},</if>
<if test="priceType != null">price_type = #{priceType},</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="deptId != null">dept_id = #{deptId},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
......
/*
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2023-06-12 10:49:16
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-06-13 16:19:48
* @FilePath: /precision-effect-web/src/api/account/account.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import request from '@/utils/request' import request from '@/utils/request'
// 查询账户列表 // 查询账户列表
...@@ -9,6 +17,15 @@ export function listAccount(query) { ...@@ -9,6 +17,15 @@ export function listAccount(query) {
}) })
} }
// 应收应付金额列表
export function getIncomeOrPayableList (query) {
return request({
url: '/trade/project/getIncomeOrPayableList',
method: 'get',
params: query
})
}
// 查询账户详细 // 查询账户详细
export function getAccount(accountId) { export function getAccount(accountId) {
return request({ return request({
......
...@@ -60,3 +60,11 @@ export function exportProject(query) { ...@@ -60,3 +60,11 @@ export function exportProject(query) {
params: query params: query
}) })
} }
// 下载导入模板
export function importTemplate() {
return request({
url: '/transaction/project/importTemplate',
method: 'get'
})
}
...@@ -324,3 +324,6 @@ ...@@ -324,3 +324,6 @@
.flex{ .flex{
display: flex; display: flex;
} }
.cup{
cursor: pointer;
}
\ No newline at end of file
<!--
* @Author: 纪泽龙 jizelong@qq.com
* @Date: 2023-06-13 15:40:04
* @LastEditors: 纪泽龙 jizelong@qq.com
* @LastEditTime: 2023-06-13 17:37:46
* @FilePath: /precision-effect-web/src/views/account/component/table.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div>
<!-- 交易项目、卖方、申请人、买方、买方经办人、应付/应收金额 -->
<el-table :data="tableData" v-loading="moneyLoading">
<el-table-column
label="交易项目"
align="center"
prop="a"
:formatter="formatter"
/>
<el-table-column label="卖方" align="center" prop="tradeTransactorName" />
<el-table-column label="申请人" align="center" prop="applyName" />
<el-table-column label="买方" align="center" prop="applyDeptName" />
<el-table-column label="买方经办人" align="center" prop="tradeDeptName" />
<template v-if="or === 'income'">
<el-table-column
label="应收金额"
align="center"
prop="pendingPayment"
/>
</template>
<template v-else>
<el-table-column
label="应付金额"
align="center"
prop="pendingPayment"
/>
</template>
</el-table>
<pagination
v-show="tableData.length > 0"
:total="total"
:page.sync="queryAccountDetailParams.pageNum"
:limit.sync="queryAccountDetailParams.pageSize"
@pagination="getOperateList"
/>
</div>
</template>
<script>
export default {
name: "",
props: {
moneyLoading: {
type: Boolean,
},
tableData: {
type: Array,
default: () => {
return [];
},
},
or: {
type: String,
default: "tableOr",
},
total: {
tyle: Number,
},
deptId: {
tyle: Number,
},
},
data() {
return {
queryAccountDetailParams: {
pageNum: 1,
pageSize: 10,
},
};
},
methods: {
getOperateList() {
this.$parent.$parent.getIncomeOrPayableList(
{
...this.queryAccountDetailParams,
deptId: this.deptId,
},
this.or
);
},
formatter(row, column, cellValue, index) {
return cellValue ? cellValue : "-";
},
},
};
</script>
<style lang="scss" scoped></style>
...@@ -201,7 +201,7 @@ ...@@ -201,7 +201,7 @@
<el-form-item label="买方" prop="tradeDeptId"> <el-form-item label="买方" prop="tradeDeptId">
<treeselect <treeselect
v-model="form.tradeDeptId" v-model="form.tradeDeptId"
:options="deptOptions" :options="formDeptOptions"
:show-count="true" :show-count="true"
placeholder="请选择部门" placeholder="请选择部门"
/> />
...@@ -396,6 +396,7 @@ export default { ...@@ -396,6 +396,7 @@ export default {
transactionProjects: [], transactionProjects: [],
deptOptions: [], deptOptions: [],
formDeptOptions: [],
priceType: "1", priceType: "1",
fileList: [], fileList: [],
transactionProjectStatus: [], transactionProjectStatus: [],
...@@ -574,6 +575,20 @@ export default { ...@@ -574,6 +575,20 @@ export default {
getTreeselect() { getTreeselect() {
treeselect().then((response) => { treeselect().then((response) => {
this.deptOptions = response.data; this.deptOptions = response.data;
this.formDeptOptions = response.data;
// 申请服务时买方不能选自己部门
var items = this.formDeptOptions[0].children;
var result = [];
var j=0;
for(var i=0; i<items.length; i++){
if(items[i].id != this.$store.state.user.deptId){
result[j] = items[i];
j++;
}
}
this.formDeptOptions[0].children = result;
console.log("formDeptOptions===",this.formDeptOptions);
}); });
}, },
changeTransactionProject(val) { changeTransactionProject(val) {
......
...@@ -56,6 +56,16 @@ ...@@ -56,6 +56,16 @@
v-hasPermi="['system:project:remove']" v-hasPermi="['system:project:remove']"
>删除</el-button> >删除</el-button>
</el-col> </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-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
...@@ -77,7 +87,7 @@ ...@@ -77,7 +87,7 @@
<el-table-column label="交易类型" align="center" prop="priceType"> <el-table-column label="交易类型" align="center" prop="priceType">
<template slot-scope="scope"> <template slot-scope="scope">
<span v-if="scope.row.priceType == '1'">定价</span> <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> </template>
</el-table-column> </el-table-column>
<el-table-column label="单价" align="center" prop="price"> <el-table-column label="单价" align="center" prop="price">
...@@ -154,11 +164,43 @@ ...@@ -154,11 +164,43 @@
<el-button @click="cancel">取 消</el-button> <el-button @click="cancel">取 消</el-button>
</div> </div>
</el-dialog> </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> </div>
</template> </template>
<script> <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 "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
...@@ -189,6 +231,21 @@ export default { ...@@ -189,6 +231,21 @@ export default {
title: "", title: "",
// 是否显示弹出层 // 是否显示弹出层
open: false, 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: { queryParams: {
pageNum: 1, pageNum: 1,
...@@ -299,6 +356,33 @@ export default { ...@@ -299,6 +356,33 @@ export default {
this.open = true; this.open = true;
this.title = "添加交易项目"; 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) { handleUpdate(row) {
this.reset(); 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