diff --git a/src/main/resources/mappers/ca/PrepaymentMapper.xml b/src/main/resources/mappers/ca/PrepaymentMapper.xml index 94ace0d..c4bfec9 100644 --- a/src/main/resources/mappers/ca/PrepaymentMapper.xml +++ b/src/main/resources/mappers/ca/PrepaymentMapper.xml @@ -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 diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index f370b3e..47feece 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -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(); diff --git a/src/main/resources/static/js/prepayment/addOperations.js b/src/main/resources/static/js/prepayment/addOperations.js index 42c146e..3029eca 100644 --- a/src/main/resources/static/js/prepayment/addOperations.js +++ b/src/main/resources/static/js/prepayment/addOperations.js @@ -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 ==="当前月份已经存在"){ diff --git a/src/main/resources/static/js/prepayment/proDetails.js b/src/main/resources/static/js/prepayment/proDetails.js new file mode 100644 index 0000000..2ef2a46 --- /dev/null +++ b/src/main/resources/static/js/prepayment/proDetails.js @@ -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(); +}); \ No newline at end of file diff --git a/src/main/resources/static/js/prepayment/proForm.js b/src/main/resources/static/js/prepayment/proForm.js index 940f681..0762c15 100644 --- a/src/main/resources/static/js/prepayment/proForm.js +++ b/src/main/resources/static/js/prepayment/proForm.js @@ -177,6 +177,7 @@ function del(id) { success: function (data) { table.reload('menuTable'); initData() + parent.table.reload('menuTable-pro'); layer.msg("删除成功"); } }); diff --git a/src/main/resources/static/js/prepayment/proList.js b/src/main/resources/static/js/prepayment/proList.js index d1ae171..5e983e9 100644 --- a/src/main/resources/static/js/prepayment/proList.js +++ b/src/main/resources/static/js/prepayment/proList.js @@ -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: ['确定', '取消'] diff --git a/src/main/resources/static/pages/prepayment/proDetails.html b/src/main/resources/static/pages/prepayment/proDetails.html new file mode 100644 index 0000000..96a9f43 --- /dev/null +++ b/src/main/resources/static/pages/prepayment/proDetails.html @@ -0,0 +1,210 @@ + + + + + + 工程预付款统计-数据更新-子页面详情 + + + + + + + +
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+ 当前状态 + +
+
+ 责任单位: + +
+
+ 往来单位: + +
+
+ 预付款类型: + +
+
+ 初始金额: + +
+
+ 首次支付日期: + +
+
+ 当前余额: + +
+
+ 账龄(月): + +
+
+ 最后更新: + +
+
+
+
+ +
+
+ +
+
+
+
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/static/pages/prepayment/proForm.html b/src/main/resources/static/pages/prepayment/proForm.html index a2c4f7b..11aaf51 100644 --- a/src/main/resources/static/pages/prepayment/proForm.html +++ b/src/main/resources/static/pages/prepayment/proForm.html @@ -213,7 +213,4 @@ - \ No newline at end of file diff --git a/src/main/resources/static/pages/prepayment/proList.html b/src/main/resources/static/pages/prepayment/proList.html index 749e893..587ab82 100644 --- a/src/main/resources/static/pages/prepayment/proList.html +++ b/src/main/resources/static/pages/prepayment/proList.html @@ -87,8 +87,18 @@ + + + + + + \ No newline at end of file