工程预付款统计功能开发

This commit is contained in:
lSun 2025-04-17 13:18:05 +08:00
parent 3c383cb3cc
commit aba9062942
9 changed files with 475 additions and 14 deletions

View File

@ -114,8 +114,7 @@
u.username as operator,
bm.created_time as createdTime,
bm.updated_time as updatedTime,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(bm.first_payment_date, '%Y%m')), 0) AS
agingMonths,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(bm.first_payment_date, '%Y%m')) + 1, 1) AS agingMonths,
CASE
WHEN bm.current_balance = 0 THEN 0
ELSE 1
@ -156,8 +155,7 @@
operator,
created_time as createdTime,
updated_time as updatedTime,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(first_payment_date, '%Y%m')),
0) AS agingMonths,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(first_payment_date, '%Y%m')) + 1, 1) AS agingMonths,
CASE
WHEN current_balance = 0 THEN 0
ELSE 1

View File

@ -32,7 +32,7 @@ function getUrlParam(key) {
}
}
}
// 获取当前月份
function getCurrentMonth() {
var now = new Date();
var year = now.getFullYear();
@ -40,6 +40,17 @@ function getCurrentMonth() {
return year + '-' + (month < 10 ? '0' + month : month);
}
// 获取上个月
function getPreviousMonth() {
var now = new Date();
// 先设置为上个月的同一天
now.setMonth(now.getMonth() - 1);
var year = now.getFullYear();
var month = now.getMonth() + 1; // 月份从 0 开始
return year + '-' + (month < 10 ? '0' + month : month);
}
function getToday() {
var now = new Date();
var year = now.getFullYear();

View File

@ -12,13 +12,27 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function(){
// 获取当前月份
var currentDate = getCurrentMonth();
console.log("currentDate:", currentDate)
var previousMonth = getPreviousMonth();
console.log("previousMonth:", previousMonth)
var now = new Date();
now.setMonth(now.getMonth() - 1, 1);
// 渲染
laydate.render({
elem: '#month',
type: 'month',
format: 'yyyy-MM',
value: currentDate,
max: currentDate,
elem: '#month', // 绑定的元素
type: 'month', // 选择类型为月份
value: currentDate, // 默认值为当前月份
// min: previousMonth, // 最小可选月份为上个月
max: currentDate, // 最大可选月份为当前月份
done: function(value, date) {
if(value < previousMonth){
layer.msg('只能选择上个月或当月', {icon: 5});
$("#month").val("")
return;
}
}
});
$("#executor").val(prepaymentUserName);
$("#prepaymentUserId").val(prepaymentUserId);
@ -44,7 +58,7 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function(){
}
// 如果是冲销,检查是否超过当前余额
if ($('#operationType').val() === 'offset') {
if ($('#operationType').val() === '1') {
if (parseFloat(value) > currentBalance) {
return '冲销金额不能大于当前余额' + currentBalance;
}
@ -176,6 +190,7 @@ function add(formData) {
parent.layer.msg(tip + '成功', { icon: 1, time: 2000 });
parent.table.reload('menuTable');
parent.initData()
parent.parent.table.reload('menuTable-pro');
} else {
top.layer.close(addLoadingMsg); //再执行关闭
if(data.resMsg ==="当前月份已经存在"){

View File

@ -0,0 +1,208 @@
var pers = checkPermission();
var example;
var table,form,laydate;
var layuiForm;
var prepaymentId = localStorage.getItem("prepaymentId");
var userId,userName;
var currentBalance;
layui.use(['table', 'form', 'laydate'], function(){
table = layui.table;
form = layui.form;
laydate = layui.laydate;
initData();
table.render({
elem: '#demo'
, url: ctxPath + '/prepayment/getOperationsList' //数据接口
, method: 'post' //方式默认是get
, toolbar: true //开启工具栏,此处显示默认图标,可以自定义模板,详见文档
, defaultToolbar: []
, where: {
prepaymentId: prepaymentId
} //post请求必须加where post请求需要的参数
, cellMinWidth: 80
, cols: [
[
{field: 'number', width: 100, title: '序号', align: 'center', type: 'numbers', fixed: 'left', rowspan: 2},
{field: 'month', title: '月份', width: 100, align: 'center', rowspan: 2},
{title: '当月执行情况', align: 'center', colspan: 4},
{title: '下月工作计划', align: 'center', colspan: 4},
{field: 'updatedTime', title: '数据更新时间', width: 260, align: 'center', rowspan: 2},
// {field: 'operation', title: '操作', width: 220, align: 'center', fixed: 'right', rowspan: 2}
{ field: 'operation', title: '操作', width: 220, align: 'center', fixed: 'right', rowspan: 2, templet: function (d) {
return `禁止操作`;
}}
],
[
{field: '', title: '冲销或新增情况', width: 240, align: 'center',
templet: function (d) {
let operationType = d.operationType;
if (operationType == 1) {
return '冲销';
} else if (operationType == 2) {
return '新增';
}
}
},
{field: 'amount', title: '冲销或新增金额', width: 240, align: 'center'},
{field: 'executor', title: '经办人', width: 200, align: 'center'},
{field: 'remarks', title: '备注', width: 280, align: 'center'},
{field: 'nextMonth', title: '月度冲销计划及措施', width: 220, align: 'center'},
{field: 'proposedAmount', title: '拟冲销金额', width: 140, align: 'center'},
{field: 'handler', title: '责任人', width: 100, align: 'center'},
{field: 'nextRemarks', title: '备注', width: 100, align: 'center'}
]
]
, id: 'menuTable'
, page: true //开启分页
, loading: true //数据加载中。。。
, limits: [10, 20, 50] //一页选择显示10,20或50条数据
, limit: 10 //一页显示10条数据
, response: {
statusCode: 200 //规定成功的状态码默认0
}
, parseData: function (res) { //将原始数据解析成 table 组件所规定的数据res为从url中get到的数据
let result;
if (res.data !== '' && res.data != null && res.data !== "null") {
if (this.page.curr) {
result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
} else {
result = res.data.slice(0, this.limit);
}
}
return {
"code": res.code, //解析接口状态
"msg": res.msg, //解析提示文本
"count": res.count, //解析数据长度
"data": result, //解析数据列表
};
}
, scroll: { // Enable horizontal scrolling
x: true,
y: true
}
});
});
function initData(){
if(prepaymentId != ""){
$.ajax({
type: 'POST',
async: false, // 默认异步true,false表示同步
url: ctxPath + '/prepayment/getListById',// 请求地址
dataType: 'json', // 服务器返回数据类型
data: {'id': prepaymentId}, //获取提交的表单字段
success: function (data) {
var resMsg = data.resMsg;
console.log("data",data);
if ("数据获取成功" === resMsg) {
let info = data.obj.prepaymentBean;
document.getElementById('projectName').textContent = info.projectName;
document.getElementById('projectCode').textContent = info.projectCode;
if(info.state == "1"){
document.getElementById('state').textContent ="未完成"
}else{
document.getElementById('state').textContent ="已冲销"
}
document.getElementById('businessUnit').textContent = info.businessUnit;
document.getElementById('contactUnit').textContent = info.contactUnit;
document.getElementById('type').textContent = info.type;
document.getElementById('initialAmount').textContent = info.initialAmount;
document.getElementById('firstPaymentDate').textContent = info.firstPaymentDate;
currentBalance = info.currentBalance;
userId = info.userId;
userName = info.userName;
document.getElementById('currentBalance').textContent = currentBalance;
document.getElementById('agingMonths').textContent = info.agingMonths;
document.getElementById('updatedTime').textContent = info.updatedTime;
}
},
error: function (XMLHttpRequest, textStatus, e) {
// layer.close(loadingMsg);
layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
}
});
}
}
function addForm(){
localStorage.setItem("prepaymentId", prepaymentId);
localStorage.setItem("currentBalance", currentBalance);
localStorage.setItem("prepaymentUserId", userId);
localStorage.setItem("prepaymentUserName", userName);
openForm("","新增");
}
function updateForm() {
localStorage.setItem("prepaymentId", prepaymentId);
var index = layer.open({
title: ["修改", 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: "./addPro.html",
area: ["60%", "80%"],
maxmin: false,
});
}
/**
* 新增-修改功能
*/
function openForm(id,title){
localStorage.setItem("id",id);
var index = layer.open({
title: [title, 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: "./addOperations.html",
area: ["60%","80%"],
maxmin: false,
});
}
function edit(id){
openForm(id,"修改")
}
function del(id) {
layer.confirm('确定要删除吗?', {
btn: ['确定', '取消']
}, function () {
$.ajax({
type: 'delete',
url: ctxPath + '/prepayment/delOperations/' + id,
success: function (data) {
table.reload('menuTable');
initData()
parent.table.reload('menuTable-pro');
layer.msg("删除成功");
}
});
layer.close(1);
});
}
$("#exportBt").click(function () {
var token = localStorage.getItem("token");
var loadingMsg = layer.msg('下载中,请稍候...', {icon: 16, scrollbar: false, time: 0});
var url = ctxPath + "/prepayment/expOperations?prepaymentId=" + prepaymentId + "&token=" + token;
var xhr = new XMLHttpRequest();
xhr.open("get", url, true);
xhr.responseType = "blob"; // 转换流
xhr.onload = function () {
layer.close(loadingMsg);
if (this.status === 200) {
var blob = this.response;
var a = document.createElement("a");
var url = window.URL.createObjectURL(blob);
a.href = url;
var projectName = document.getElementById('projectName').textContent
a.download = "工程预付款统计-"+projectName+".xlsx"; // 文件名
} else {
layer.msg('导出发生异常,请稍后重试', {icon: 16, scrollbar: false, time: 2000});
}
a.click()
window.URL.revokeObjectURL(url)
};
xhr.send();
});

View File

@ -177,6 +177,7 @@ function del(id) {
success: function (data) {
table.reload('menuTable');
initData()
parent.table.reload('menuTable-pro');
layer.msg("删除成功");
}
});

View File

@ -109,6 +109,17 @@ function openQuery(id, title) {
});
}
function viewDetails(id,title){
localStorage.setItem("prepaymentId", id);
var index = layer.open({
title: [title, 'color:#3B70A1;background-color:#E8ECEB;font-size:20px'],
type: 2,
content: 'proDetails.html',
area: ["95%", "90%"],
maxmin: false,
});
}
function del(id) {
layer.confirm('确定要删除吗?', {
btn: ['确定', '取消']

View File

@ -0,0 +1,210 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>工程预付款统计-数据更新-子页面详情</title>
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/dataTables.bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="../../layui-v2.8.3/layui/css/layui.css">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/work/publicStyles.css">
<style>
.project-header {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.project-icon {
width: 50px;
height: 50px;
border-radius: 50%;
background-color: #FF5722;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
margin-right: 15px;
}
.project-info {
flex: 1;
}
.project-title {
font-size: 18px;
font-weight: bold;
margin-bottom: 5px;
}
.project-id {
font-size: 14px;
color: #999;
}
.project-actions {
display: flex;
gap: 10px;
}
.project-details {
display: flex;
flex-wrap: wrap;
margin-bottom: 20px;
background-color: #fff;
padding: 15px;
border-radius: 2px;
}
.detail-item {
width: 20%;
margin-bottom: 10px;
font-size: 14px;
}
.status-dot {
display: inline-block;
width: 8px;
height: 8px;
border-radius: 50%;
margin-right: 5px;
}
.status-incomplete {
background-color: #FF5722;
}
.status-new {
color: #5FB878;
}
.status-offset {
color: #1E9FFF;
}
.search-form {
background-color: #fff;
padding: 15px;
margin-bottom: 20px;
border-radius: 2px;
}
.main-container {
padding: 15px;
}
.layui-table-page {
text-align: center;
}
.operation-link {
padding: 0 5px;
}
.disabled-operation {
color: #d2d2d2;
cursor: not-allowed;
}
#addBtn {
background-color: #f59a23 !important;
}
#exportBtn {
background-color: #f2f2f2 !important;
color: #000000 !important;
border: 1px solid #ababab !important;
}
/* Add these styles for horizontal scrolling */
.widget-body {
overflow-x: auto;
width: 100%;
}
.layui-table-view {
width: auto !important;
min-width: 100%;
}
</style>
</head>
<body class="layui-layout-body" style="background-color: #f2f2f2;">
<div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<header style="height: 100%">
<div class="main-container">
<div class="project-header">
<div class="project-icon"></div>
<div class="project-info">
<div class="project-title" id="projectName"></div>
<div class="project-id" id="projectCode"></div>
</div>
<div class="project-actions">
<button id="exportBt" class="layui-btn layui-btn-primary">
导出
</button>
</div>
</div>
<div class="project-details">
<div class="detail-item">
<span>当前状态</span>
<span ><span class="status-dot status-incomplete" ></span> <span id="state"></span></span>
</div>
<div class="detail-item">
<span>责任单位:</span>
<span id="businessUnit"></span>
</div>
<div class="detail-item">
<span>往来单位:</span>
<span id="contactUnit"></span>
</div>
<div class="detail-item">
<span>预付款类型:</span>
<span id="type"></span>
</div>
<div class="detail-item">
<span>初始金额:</span>
<span id="initialAmount"></span>
</div>
<div class="detail-item">
<span>首次支付日期:</span>
<span id="firstPaymentDate"></span>
</div>
<div class="detail-item">
<span>当前余额:</span>
<span id="currentBalance"></span>
</div>
<div class="detail-item">
<span>账龄(月)</span>
<span id="agingMonths"></span>
</div>
<div class="detail-item">
<span>最后更新:</span>
<span id="updatedTime"></span>
</div>
</div>
</div>
</header>
<div style="margin-left: 15px;margin-right: 15px;">
<div class="widget-body">
<table id="demo" lay-filter="test" class="layui-table" lay-size="lg">
</table>
</div>
</div>
</div>
</div>
</body>
</html>
<script type="text/javascript" src="../../js/libs/jquery-3.6.0.min.js"></script>
<script type="text/javascript" src="../../js/jq.js"></script>
<script type="text/javascript" src="../../js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../../layui-v2.8.3/layui/layui.js"></script>
<script type="text/javascript" src="../../js/my/permission.js"></script>
<script type="text/javascript" src="../../js/publicJs.js"></script>
<script type="text/javascript" src="../../js/common_methon.js"></script>
<script type="text/javascript" src="../../js/prepayment/proDetails.js"></script>

View File

@ -213,7 +213,4 @@
<script type="text/javascript" src="../../js/my/permission.js"></script>
<script type="text/javascript" src="../../js/publicJs.js"></script>
<script type="text/javascript" src="../../js/common_methon.js"></script>
<script type="text/html" id="gysmcView">
<a style="color: #35B3F1;cursor:pointer;" onclick="buttonquery('{{d.htmcid}}')">{{d.gysmc}}</a>
</script>
<script type="text/javascript" src="../../js/prepayment/proForm.js"></script>

View File

@ -87,8 +87,18 @@
<script type="text/javascript" src="../../js/common_methon.js"></script>
<script type="text/javascript" src="../../js/prepayment/proList.js"></script>
<!--<script type="text/html" id="toolsBar">-->
<!-- <a style="color: #009688;font-size: 16px;cursor:pointer;" onclick="openQuery('{{d.id}}', '数据更新')">更新</a>-->
<!-- <span> | </span>-->
<!-- <a style="color: #009688;font-size: 16px;cursor:pointer;" onclick="del('{{d.id}}')">删除</a>-->
<!--</script>-->
<script type="text/html" id="toolsBar">
{{# if(d.state == 0) { }}
<a style="color: #009688;font-size: 16px;cursor:pointer;" onclick="viewDetails('{{d.id}}')">详情</a>
{{# } else { }}
<a style="color: #009688;font-size: 16px;cursor:pointer;" onclick="openQuery('{{d.id}}', '数据更新')">更新</a>
<span> | </span>
<a style="color: #009688;font-size: 16px;cursor:pointer;" onclick="del('{{d.id}}')">删除</a>
{{# } }}
</script>