工程预付款统计功能修改、工程预付款统计-字段开发

This commit is contained in:
lSun 2025-06-12 14:34:20 +08:00
parent 676a937b20
commit ac2722c3cb
11 changed files with 744 additions and 29 deletions

View File

@ -2,15 +2,19 @@ package com.bonus.boot.manager.ca.bm.controller;
import com.bonus.boot.manager.ca.bm.entity.GoodsInfoBean;
import com.bonus.boot.manager.ca.bm.entity.OperationsBean;
import com.bonus.boot.manager.ca.bm.entity.PayAccountInfoBean;
import com.bonus.boot.manager.ca.bm.entity.PrepaymentBean;
import com.bonus.boot.manager.ca.bm.service.PrepaymentService;
import com.bonus.boot.manager.manager.annotation.LogAnnotation;
import com.bonus.boot.manager.manager.entity.R;
import com.bonus.boot.manager.manager.model.SysUser;
import com.bonus.boot.manager.manager.table.PageTableHandler;
import com.bonus.boot.manager.manager.table.PageTableRequest;
import com.bonus.boot.manager.manager.table.PageTableResponse;
import com.bonus.boot.manager.manager.utils.AjaxRes;
import com.bonus.boot.manager.manager.utils.GlobalConst;
import com.bonus.boot.manager.manager.utils.UserUtil;
import com.bonus.boot.manager.tools.entity.ToolsBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@ -41,7 +45,6 @@ public class PrepaymentController {
@PostMapping("/getList")
@ApiOperation(value = "查询")
// @PreAuthorize("hasAuthority('sys:prepayment:query')")
public R getList(PageTableRequest request) {
List<PrepaymentBean> list = service.getList(request.getParams(), request.getOffset(), request.getLimit());
return list.size() > 0 ? R.okTable(list, list.size()):R.failTable("暂无数据");
@ -50,7 +53,6 @@ public class PrepaymentController {
@RequestMapping(value = "addPrepayment", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "工程预付款统计-新增")
// @PreAuthorize("hasAuthority('sys:payable:add')")
public AjaxRes addPrepayment(@RequestBody PrepaymentBean prepaymentBean) {
AjaxRes ar = new AjaxRes();
int i = service.addPrepayment(prepaymentBean);
@ -81,7 +83,6 @@ public class PrepaymentController {
@RequestMapping(value = "updatePrepayment", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "工程预付款统计-修改")
// @PreAuthorize("hasAuthority('sys:payable:add')")
public AjaxRes updatePrepayment(@RequestBody PrepaymentBean bean) {
AjaxRes ar = new AjaxRes();
int i = service.updatePrepayment(bean);
@ -96,7 +97,6 @@ public class PrepaymentController {
@LogAnnotation
@DeleteMapping("/delPrepayment/{id}")
@ApiOperation(value = "工程预付款统计-删除")
// @PreAuthorize("hasAuthority('sys:goods:del')")
public void delPrepayment(@PathVariable Long id) {
service.delPrepayment(id);
}
@ -105,7 +105,6 @@ public class PrepaymentController {
@RequestMapping(value = "addOperations", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "工程预付款统计-数据更新-新增")
// @PreAuthorize("hasAuthority('sys:payable:add')")
public AjaxRes addOperations(@RequestBody OperationsBean bean) {
AjaxRes ar = new AjaxRes();
int i = service.addOperations(bean);
@ -122,7 +121,6 @@ public class PrepaymentController {
@RequestMapping(value = "updateOperations", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "工程预付款统计-数据更新-修改")
// @PreAuthorize("hasAuthority('sys:payable:add')")
public AjaxRes updateOperations(@RequestBody OperationsBean bean) {
AjaxRes ar = new AjaxRes();
int i = service.updateOperations(bean);
@ -153,7 +151,6 @@ public class PrepaymentController {
@LogAnnotation
@DeleteMapping("/delOperations/{id}")
@ApiOperation(value = "工程预付款统计-数据更新-删除")
// @PreAuthorize("hasAuthority('sys:goods:del')")
public void delOperations(@PathVariable Long id) {
service.delOperations(id);
}
@ -163,7 +160,6 @@ public class PrepaymentController {
@PostMapping("/getOperationsList")
@ApiOperation(value = "数据更新-查询")
// @PreAuthorize("hasAuthority('sys:prepayment:query')")
public R getOperationsList(PageTableRequest request) {
List<OperationsBean> list = service.getOperationsList(request.getParams(), request.getOffset(), request.getLimit());
return list.size() > 0 ? R.okTable(list, list.size()):R.failTable("暂无数据");
@ -181,4 +177,63 @@ public class PrepaymentController {
service.expOperations(response,request.getParams());
}
// @GetMapping("/getDictList")
// @ApiOperation(value = "查询")
// public R getDictList(PageTableRequest request) {
// List<PrepaymentBean> list = service.getDictList(request.getParams(), request.getOffset(), request.getLimit());
// return list.size() > 0 ? R.okTable(list, list.size()):R.failTable("暂无数据");
// }
@GetMapping("/getDictList")
@ApiOperation(value = "查询")
public PageTableResponse getDictList(PageTableRequest request) {
return new PageTableHandler(new PageTableHandler.CountHandler() {
@Override
public int count(PageTableRequest request) {
return service.getDictCount(request.getParams());
}
}, new PageTableHandler.ListHandler() {
@Override
public List<PrepaymentBean> list(PageTableRequest request) {
List<PrepaymentBean> list = service.getDictList(request.getParams(), request.getOffset(), request.getLimit());
return list;
}
}).handle(request);
}
@LogAnnotation
@GetMapping("/{id}")
@ApiOperation(value = "根据id获取内容")
public PrepaymentBean getById(@PathVariable Long id) {
return service.getById(id);
}
@LogAnnotation
@PostMapping("/addOrUpdate")
@ApiOperation(value = "保存信息")
public void addOrUpdate(@RequestBody PrepaymentBean o) {
service.addOrUpdate(o);
}
@LogAnnotation
@DeleteMapping("/delDict/{id}")
@ApiOperation(value = "删除信息")
public void delDict(@PathVariable Long id) {
service.delDict(id);
}
@LogAnnotation
@GetMapping("/getBusinessUnit")
@ApiOperation(value = "责任单位下拉选")
public List<PrepaymentBean> getBusinessUnit() {
return service.getBusinessUnit();
}
@LogAnnotation
@GetMapping("/getType")
@ApiOperation(value = "预付款类型下拉选")
public List<PrepaymentBean> getType() {
return service.getType();
}
}

View File

@ -2,6 +2,7 @@ package com.bonus.boot.manager.ca.bm.dao;
import com.bonus.boot.manager.ca.bm.entity.OperationsBean;
import com.bonus.boot.manager.ca.bm.entity.PrepaymentBean;
import com.bonus.boot.manager.tools.entity.ToolsBean;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@ -47,4 +48,22 @@ public interface PrepaymentDao {
* @return
*/
OperationsBean getOperationsById(String id);
List<PrepaymentBean> getDictList(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
PrepaymentBean getById(Long id);
void update(PrepaymentBean o);
void add(PrepaymentBean o);
void delDict(Long id);
int getDictCount(@Param("params") Map<String, Object> params);
int getByIdDict(Long id);
List<PrepaymentBean> getBusinessUnit();
List<PrepaymentBean> getType();
}

View File

@ -12,10 +12,13 @@ import java.math.BigDecimal;
@Data
public class PrepaymentBean {
private String id;
private String name;
private String projectCode;//承揽合同编码
private String projectName;//承揽合同名称工程名称
private String businessUnitId;//责任单位
private String businessUnit;//责任单位
private String contactUnit;//往来单位
private String typeId;//预付款类型
private String type;//预付款类型
@JsonSerialize(using = ToStringSerializer.class)

View File

@ -2,6 +2,7 @@ package com.bonus.boot.manager.ca.bm.service;
import com.bonus.boot.manager.ca.bm.entity.OperationsBean;
import com.bonus.boot.manager.ca.bm.entity.PrepaymentBean;
import com.bonus.boot.manager.tools.entity.ToolsBean;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@ -101,4 +102,25 @@ public interface PrepaymentService {
* @param params
*/
void expOperations(HttpServletResponse response, Map<String, Object> params);
/**
* 查询字典表
* @param params
* @param offset
* @param limit
* @return
*/
List<PrepaymentBean> getDictList(Map<String, Object> params, Integer offset, Integer limit);
PrepaymentBean getById(Long id);
void addOrUpdate(PrepaymentBean o);
void delDict(Long id);
int getDictCount(Map<String, Object> params);
List<PrepaymentBean> getBusinessUnit();
List<PrepaymentBean> getType();
}

View File

@ -6,7 +6,9 @@ import com.bonus.boot.manager.ca.bm.dao.PrepaymentDao;
import com.bonus.boot.manager.ca.bm.entity.OperationsBean;
import com.bonus.boot.manager.ca.bm.entity.PrepaymentBean;
import com.bonus.boot.manager.ca.bm.service.PrepaymentService;
import com.bonus.boot.manager.manager.entity.LoginUser;
import com.bonus.boot.manager.manager.utils.UserUtil;
import com.bonus.boot.manager.tools.entity.ToolsBean;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -327,4 +329,48 @@ public class PrepaymentServiceImpl implements PrepaymentService {
writer.close();
IoUtil.close(out);
}
@Override
public List<PrepaymentBean> getDictList(Map<String, Object> params, Integer offset, Integer limit) {
return dao.getDictList(params,offset,limit);
}
@Override
public PrepaymentBean getById(Long id) {
return dao.getById(id);
}
@Override
public void addOrUpdate(PrepaymentBean o) {
if (o.getId() != null && !o.getId().isEmpty()){
dao.update(o);
}else {
dao.add(o);
}
}
@Override
public void delDict(Long id) {
int i = dao.getByIdDict(id);
if(i>0){
throw new IllegalArgumentException("该类别已存在,不可删除");
}else{
dao.delDict(id);
}
}
@Override
public int getDictCount(Map<String, Object> params) {
return dao.getDictCount(params);
}
@Override
public List<PrepaymentBean> getBusinessUnit() {
return dao.getBusinessUnit();
}
@Override
public List<PrepaymentBean> getType() {
return dao.getType();
}
}

View File

@ -27,6 +27,12 @@
#{handler},
#{nextRemarks}, '1', #{operator},#{currentBalance})
</insert>
<insert id="add">
INSERT INTO `bm_project_prepayment_dict` ( `name`, `remarks`, `type` )
VALUES ( #{name}, #{remarks}, #{type} )
</insert>
<update id="updatePrepaymentId">
UPDATE `bm_project_prepayment`
SET `current_balance` = #{currentBalanceNew},
@ -85,6 +91,10 @@
WHERE `id` = #{id} and is_active = '1'
</update>
<update id="update">
UPDATE `bm_project_prepayment_dict` SET `name` = #{name}, `remarks` = #{remarks}, `type` = #{type} WHERE `id` = #{id}
</update>
<delete id="delPrepayment">
UPDATE `bm_project_prepayment`
SET `is_active` = '0',
@ -99,14 +109,20 @@
WHERE `id` = #{id}
</delete>
<delete id="delDict">
UPDATE `bm_project_prepayment_dict` SET `is_active` = '0' WHERE `id` = #{id}
</delete>
<select id="getList" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT
bm.id,
bm.project_code as projectCode,
bm.project_name as projectName,
bm.business_unit as businessUnit,
dict2.id as businessUnitId,
dict2.`name` as businessUnit,
bm.contact_unit as contactUnit,
bm.type,
dict1.id as typeId,
dict1.name as type,
bm.initial_amount as initialAmount,
bm.first_payment_date as firstPaymentDate,
bm.current_balance as currentBalance,
@ -121,6 +137,8 @@
END AS state
FROM
`bm_project_prepayment` bm
LEFT JOIN bm_project_prepayment_dict dict1 on dict1.id = bm.type
LEFT JOIN bm_project_prepayment_dict dict2 on dict2.id = bm.business_unit
LEFT JOIN sys_user u ON u.id = bm.operator
WHERE bm.is_active = '1'
<if test="params.keyword != null and params.keyword != ''">
@ -139,16 +157,18 @@
</select>
<select id="getListById" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT id,
SELECT bm.id,
project_code as projectCode,
project_name as projectName,
business_unit as businessUnit,
dict2.id as businessUnitId,
dict2.`name` as businessUnit,
contact_unit as contactUnit,
type,
dict1.id as typeId,
dict1.name as type,
initial_amount as initialAmount,
first_payment_date as firstPaymentDate,
current_balance as currentBalance,
remarks,
bm.remarks,
operator,
created_time as createdTime,
updated_time as updatedTime,
@ -157,9 +177,11 @@
WHEN current_balance = 0 THEN 0
ELSE 1
END AS state
FROM `bm_project_prepayment`
WHERE is_active = '1'
and id = #{id}
FROM `bm_project_prepayment` bm
LEFT JOIN bm_project_prepayment_dict dict1 on dict1.id = bm.type
LEFT JOIN bm_project_prepayment_dict dict2 on dict2.id = bm.business_unit
WHERE bm.is_active = '1'
and bm.id = #{id}
</select>
<select id="getOperationsList" resultType="com.bonus.boot.manager.ca.bm.entity.OperationsBean">
@ -197,4 +219,46 @@
LEFT JOIN sys_user u2 ON u2.id = bm.executor
WHERE bm.is_active = '1' AND bm.id= #{id}
</select>
<select id="getDictList" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT id,`name`,`remarks`,type FROM bm_project_prepayment_dict
WHERE IS_ACTIVE = 1
<if test="params.name != null and params.name != ''">
AND `name` LIKE CONCAT('%', #{params.name}, '%')
</if>
<if test="params.type != null and params.type != ''">
AND type = #{params.type}
</if>
limit #{offset}, #{limit}
</select>
<select id="getById" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT id,`name`,`remarks`,type FROM bm_project_prepayment_dict
WHERE IS_ACTIVE = 1 AND id = #{id}
</select>
<select id="getDictCount" resultType="java.lang.Integer">
SELECT count(1)
FROM bm_project_prepayment_dict
WHERE IS_ACTIVE = 1
<if test="params.name != null and params.name != ''">
AND `name` LIKE CONCAT('%', #{params.name}, '%')
</if>
</select>
<select id="getByIdDict" resultType="java.lang.Integer">
SELECT count(1)
FROM bm_project_prepayment
WHERE IS_ACTIVE = 1 AND( type = #{id} or business_unit = #{id})
</select>
<select id="getBusinessUnit" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT id,`name` FROM bm_project_prepayment_dict
WHERE IS_ACTIVE = 1 AND type = '1'
</select>
<select id="getType" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT id,`name` FROM bm_project_prepayment_dict
WHERE IS_ACTIVE = 1 AND type = '2'
</select>
</mapper>

View File

@ -26,11 +26,11 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function(){
// min: previousMonth, // 最小可选月份为上个月
max: currentDate, // 最大可选月份为当前月份
done: function(value, date) {
if(value < previousMonth){
/*if(value < previousMonth){
layer.msg('只能选择上个月或当月', {icon: 5});
$("#month").val("")
return;
}
}*/
}
});

View File

@ -9,6 +9,8 @@ layui.use(['table', 'layer', 'laydate', 'jquery', 'form'], function(){
elem: '#firstPaymentDate',
max: getToday(),
});
getBusinessUnit("");
getType("");
initData();
form.render();
// 自定义验证规则
@ -38,9 +40,9 @@ function initData(){
$("#id").val(info.id);
$("#projectCode").val(info.projectCode);
$("#projectName").val(info.projectName);
$("#businessUnit").val(info.businessUnit);
$("#businessUnit").val(info.businessUnitId);
$("#contactUnit").val(info.contactUnit);
$("#type").val(info.type);
$("#type").val(info.typeId);
$("#initialAmount").val(info.initialAmount);
@ -106,4 +108,52 @@ function add(formData) {
top.layer.close(addLoadingMsg); //再执行关闭
}
});
}
function getBusinessUnit(id){
$("#businessUnit").empty();
$.ajax({
url: ctxPath + '/prepayment/getBusinessUnit',
method: 'get',
async: false,
success: function (data) {
var str = '';
if (data.length > 0) {
str += '<option value="">请选择或搜索关键字</option>';
for (var i = 0; i < data.length; i++) {
if (id == data[i].id) {
str += '<option selected value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
} else {
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
}
}
}
$("#businessUnit").append(str);
layui.form.render('select')
}
})
}
function getType(id){
$("#type").empty();
$.ajax({
url: ctxPath + '/prepayment/getType',
method: 'get',
async: false,
success: function (data) {
var str = '';
if (data.length > 0) {
str += '<option value="">请选择或搜索关键字</option>';
for (var i = 0; i < data.length; i++) {
if (id == data[i].id) {
str += '<option selected value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
} else {
str += '<option value=\'' + data[i].id + '\'>' + data[i].name + '</option>';
}
}
}
$("#type").append(str);
layui.form.render('select')
}
})
}

View File

@ -22,6 +22,10 @@
color: #333; /* 字体颜色 */
border-color: #ddd; /* 边框颜色 */
}
.layui-input, .layui-textarea{
width: 89%;
}
</style>
</head>
<body>
@ -30,54 +34,60 @@
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" style="width: 30%">承揽合同编码:</label>
<div class="layui-input-block">
<input style="width: 85%" type="text" name="projectCode" id="projectCode" maxlength="50" class="layui-input">
<input style="width: 89%" type="text" name="projectCode" id="projectCode" maxlength="50" class="layui-input">
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" style="width: 30%"><i class="tip-required" style="color: red;font-size: 20px">*</i> 承揽合同名称(工程名称):</label>
<div class="layui-input-block">
<input style="width: 85%" type="text" name="projectName" id="projectName" maxlength="50" lay-verify="required" class="layui-input">
<input style="width: 89%" type="text" name="projectName" id="projectName" maxlength="50" lay-verify="required" class="layui-input">
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" style="width: 30%"> <i class="tip-required" style="color: red;font-size: 20px">*</i> 责任单位:</label>
<div class="layui-input-block">
<input style="width: 85%" type="text" name="businessUnit" id="businessUnit" maxlength="50" lay-verify="required" class="layui-input">
<select name="businessUnit" id="businessUnit" lay-verify="required" lay-search="">
<option value="">请选择</option>
</select>
<!-- <input style="width: 89%" type="text" name="businessUnit" id="businessUnit" maxlength="50" lay-verify="required" class="layui-input">-->
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" style="width: 30%"><i class="tip-required" style="color: red;font-size: 20px">*</i>往来单位:</label>
<div class="layui-input-block">
<input style="width: 85%" type="text" name="contactUnit" id="contactUnit" maxlength="50" lay-verify="required" class="layui-input">
<input style="width: 89%" type="text" name="contactUnit" id="contactUnit" maxlength="50" lay-verify="required" class="layui-input">
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" style="width: 30%"><i class="tip-required" style="color: red;font-size: 20px">*</i>预付款类型:</label>
<div class="layui-input-block">
<input style="width: 85%" type="text" name="type" id="type" maxlength="50" lay-verify="required" class="layui-input">
<select name="type" id="type" lay-verify="required" lay-search="">
<option value="">请选择</option>
</select>
<!-- <input style="width: 89%" type="text" name="type" id="type" maxlength="50" lay-verify="required" class="layui-input">-->
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" style="width: 30%"><i class="tip-required" style="color: red;font-size: 20px">*</i> 初始金额:</label>
<div class="layui-input-block">
<input style="width: 85%" type="text" name="initialAmount" id="initialAmount" maxlength="10" lay-verify="required|je" class="layui-input" >
<input style="width: 89%" type="text" name="initialAmount" id="initialAmount" maxlength="10" lay-verify="required|je" class="layui-input" >
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%">
<label class="layui-form-label" style="width: 30%"><i class="tip-required" style="color: red;font-size: 20px">*</i>首次支付日期:</label>
<div class="layui-input-block">
<input style="width: 85%" type="text" class="layui-input" id="firstPaymentDate" name="firstPaymentDate" lay-verify="required" placeholder="yyyy-MM-dd" readonly>
<input style="width: 89%" type="text" class="layui-input" id="firstPaymentDate" name="firstPaymentDate" lay-verify="required" placeholder="yyyy-MM-dd" readonly>
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%">
<label class="layui-form-label" style="width: 30%">备注:</label>
<div class="layui-input-block">
<textarea type="text" name="remarks" id="remarks" style="height: 186px; width: 85%; box-sizing: border-box; padding: 10px; font-size: 16px; border-color: #d2d2d2; resize: vertical" autocomplete="off" maxlength="200"></textarea>
<textarea type="text" name="remarks" id="remarks" style="height: 186px; width: 89%; box-sizing: border-box; padding: 10px; font-size: 16px; border-color: #d2d2d2; resize: vertical" autocomplete="off" maxlength="200"></textarea>
</div>
</div>

View File

@ -0,0 +1,172 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<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">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
<style>
/* CSS样式 */
#my-button {
position: absolute;
top: 15px;
right: 450px;
}
.layui-icon{
font-size: 80px!important;
}
.layui-input, .layui-textarea{
width: 100%;
}
</style>
</head>
<body>
<form class="layui-form" action="" method="post" onsubmit="return false">
<input type="hidden" id="id" name="id">
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" ><i class="tip-required" style="color: red;font-size: 20px">*</i> 类型:</label>
<div class="layui-input-block" >
<select name="type" id="type" lay-verify="required" class="layui-input" >
<option value="">请选择</option>
<option value="1">责任单位</option>
<option value="2">预付款类型</option>
</select>
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" ><i class="tip-required" style="color: red;font-size: 20px">*</i> 名称:</label>
<div class="layui-input-block">
<input type="text" name="name" id="name" maxlength="30" lay-verify="required" class="layui-input">
</div>
</div>
<div class="layui-input-inline"style="float: left;width: 50%;margin-top: 2%;margin-left: 20%" >
<label class="layui-form-label" ><i class="tip-required" style="color: red;font-size: 20px">*</i> 备注:</label>
<div class="layui-input-block">
<input type="text" name="remarks" id="remarks" maxlength="30" lay-verify="required" class="layui-input">
</div>
</div>
<div class="form-actions">
<div class="col-md-12">
<button class="btn btn-primary" id="my-button" type="submit" onclick="add()" style="width: 100px">
<i class="fa fa-save"></i> 保存
</button>
</div>
</div>
</form>
<script type="text/javascript" src="../../js/libs/jquery-3.6.0.js"></script>
<script type="text/javascript" src="../../js/jq.js"></script>
<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script type="text/javascript" src="../../js/publicJs.js"></script>
<script type="text/javascript" src="../../layui-v2.8.3/layui/layui.js"></script>
<script type="text/javascript">
var id = localStorage.getItem("id");
let form;
layui.use(['table', 'upload', 'layer', 'laydate', 'jquery', 'form'], function(){
var layer = layui.layer;
form = layui.form;
initData();
form.render();
var upload = layui.upload;
//图片上传执行实例
let uploadInst1 = upload.render({
elem: '#upFileBtn1', //绑定元素
url: ctxPath + "/tools/upload",
accept: 'file', //允许上传的文件类型
auto: true, //是否自动上传
multiple: false, //是否支持多文件上传
data:{
photoType: 'toolsPackage'
},
choose: function(obj){ //选择文件后的回调函数
code = "0";
//预读本地文件,如果是多文件,则会遍历。(不支持ie8/9)
obj.preview(function(index, file, result){
// $("#fileNameView").val(file.name);
});
},
done: function(res, index, upload){ //上传完毕的回调函数
$("#url").val(res.data.url);
code = "1";
// layer.msg("文件上传成功",{icon:1})
}
,error: function(){
console.log("请求异常回调");
}
});
//图片上传执行实例
let uploadInst2 = upload.render({
elem: '#upFileBtn2', //绑定元素
url: ctxPath + "/tools/upload",
accept: 'file', //允许上传的文件类型
auto: true, //是否自动上传
multiple: false, //是否支持多文件上传
data:{
photoType: 'toolsPackage'
},
choose: function(obj){ //选择文件后的回调函数
code = "0";
//预读本地文件,如果是多文件,则会遍历。(不支持ie8/9)
obj.preview(function(index, file, result){
// $("#fileNameView").val(file.name);
});
},
done: function(res, index, upload){ //上传完毕的回调函数
$("#operManual").val(res.data.url);
code = "1";
// layer.msg("文件上传成功",{icon:1})
}
,error: function(){
console.log("请求异常回调");
}
});
});
function initData(){
if(id != ""){
$.ajax({
type : 'get',
url : ctxPath + '/prepayment/'+id,
async : false,
success : function(data) {
$("#type").val(data.type);
$("#name").val(data.name);
$("#remarks").val(data.remarks);
}
});
}
}
function add() {
var formdata = $("#form");
if (id == "0"){
formdata.id = "";
}else{
formdata.id = id;
}
formdata.type = $("#type").val();
formdata.name = $("#name").val();
formdata.remarks = $("#remarks").val();
$.ajax({
type : 'post',
url : ctxPath + '/prepayment/addOrUpdate',
contentType: "application/json; charset=utf-8",
data : JSON.stringify(formdata),
success : function(data) {
parent.example.ajax.reload();
parent.layer.closeAll();
top.layer.close(); //再执行关闭
parent.layer.msg('成功', {icon: 1, time: 2000});
},
});
}
</script>
</body>
</html>

View File

@ -0,0 +1,274 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<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/css/layui.css">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/work/publicStyles.css">
<style>
button{
border-radius: 7px !important;
}
#addBtn{
background-color: #f59a23 !important;
}
#exportBt{
background-color: #f2f2f2 !important;
color: #000000 !important;
border: 1px solid #ababab !important;
}
.layui-input, .layui-textarea{
width: 100%;
}
</style>
</head>
<body>
<div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12" >
<header style="height: 100%">
<div align="left">
<table style="width: 100%">
<tr>
<td>
<form class="form-inline layui-form" onsubmit="return false">
<div class="form-group">
<div class="layui-inline">
<div class="layui-input-inline">
<input id="name" type="text" class="layui-input" style="width: 200px" placeholder="请输入关键字">
</div>
</div>
<div class="layui-input-inline" >
<select name="type" id="type" class="layui-input" >
<option value="">请选择</option>
<option value="1">责任单位</option>
<option value="2">预付款类型</option>
</select>
</div>
<button id="searchBt" class="layui-btn" style="margin-top: -0.3%; margin-left: 15px;">
搜索
</button>
<button id="addBtn" class="layui-btn" onclick="addForm()" style="margin-top: -0.3%;">
添加
</button>
</div>
</form>
</td>
</tr>
</table>
</div>
</header>
<div>
<div class="widget-body no-padding">
<table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
<thead>
<tr>
<th>序号</th>
<th>类别</th>
<th>名称</th>
<th>备注</th>
<th>操作</th>
</tr>
</thead>
<tbody>
</tbody>
</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/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">
var pers = checkPermission();
var example;
var form;
var layuiForm;
layui.use(['form', 'laydate', 'upload'], function () {
form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
layuiForm = form;
form.render();
form.verify({});
});
init();
function init(){
example =
$('#dt-table').DataTable({
"searching": false,
"processing": false,
"serverSide" : true,
"pagingType": "full_numbers", //首页|尾页saveZipButton
"language": {
"url": ctxPath + "/js/plugin/datatables/Chinese.lang"
},
"ajax": {
"url" : ctxPath + "/prepayment/getDictList",
"type":"get",
"data":function(d){
d.name = $('#name').val();
d.type = $('#type').val();
},
"error":function(xhr, textStatus, errorThrown){
var msg = xhr.responseText;
var response = JSON.parse(msg);
var code = response.code;
var message = response.message;
if (code == 400) {
layer.msg(message);
} else if (code == 401) {
localStorage.removeItem("token");
layer.msg("token过期请先登录", {shift: -1, time: 1000}, function(){
location.href = ctxPath + '/login.html';
});
} else if (code == 403) {
layer.msg('未授权');
} else if (code == 500) {
layer.msg('系统错误:' + message);
}
}
},
"drawCallback": function() {
var thisDataTable = $('#dt-table').DataTable();
$(".pagination").append("<li>" +
"<a class='paginate_button' style='padding:4px;' href='#' tabindex='0'><input style='margin:0px;width:40px;' id='changePage'></a>" +
"<a class='paginate_button' style='margin-bottom:1px' href='#' tabindex='0' id='dataTable-btn'>确认</a></li>");
//点击按钮跳转指定页数
$('#dataTable-btn').click(function (e) {
if ($("#changePage").val() && $("#changePage").val() > 0) {
var redirectpage = $("#changePage").val() - 1;
} else {
var redirectpage = 0;
}
thisDataTable.page(redirectpage).draw( 'page' );
});
//敲击回车键跳转指定页数
$("#changePage").keypress(function (e) {
if(event.keyCode==13){
if ($("#changePage").val() && $("#changePage").val() > 0) {
var redirectpage = $("#changePage").val() - 1;
} else {
var redirectpage = 0;
}
thisDataTable.page(redirectpage).draw( 'page' );
}
});
},
"dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-2 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
"columns": [
{
width: '5%',
data: function (row, type, set, meta) {
var c = meta.settings._iDisplayStart + meta.row + 1;
return c;
},
"orderable": false
},
{ "data": "", "defaultContent": "",
"render": function (data, type, row) {
var type = row['type'];
if(type == 1){
return "责任单位";
}else if(type == 2){
return "预付款类型";
}
},
},
{ "data": "name", "defaultContent": ""},
{ "data": "remarks", "defaultContent": ""},
{
"data": "",
"defaultContent": "",
"orderable":false,
"render": function (data, type, row) {
var id = row['id'];
var edit = buttonupdte(id, "", pers);
var del = buttonDel(id, "", pers);
return edit + del;
},
},
],
"order": []
} );
}
//修改按键
function buttonupdte(id, permission, pers){
if(permission != ""){
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<a style='color: #009688;font-size: 16px;cursor:pointer;' onclick='openForm(\"" + id +"\",\"" +'修改' +"\")'>修改</a>");
return btn.prop("outerHTML");
}
function addForm(){
openForm("","新增");
}
/**
* 新增-修改功能
*/
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: "proDictForm.html",
area: ["60%","80%"],
maxmin: false,
});
}
function buttonDel(id, permission, pers){
if(permission != ""){
if ($.inArray(permission, pers) < 0) {
return "";
}
}
var btn = $("<a style='color: #009688;font-size: 16px;cursor:pointer;' onclick='del(\"" + id +"\")'><span style='color: #0e0e0e;'> | </span>删除</a>");
return btn.prop("outerHTML");
}
function del(id){
layer.confirm('确定要删除吗?', {
btn : [ '确定', '取消' ]
}, function() {
$.ajax({
type : 'delete',
url : ctxPath + '/prepayment/delDict/'+id,
success : function(data) {
example.ajax.reload();
layer.msg("删除成功");
}
});
layer.close(1);
});
}
$("#searchBt").click(function(){
example.ajax.reload();
});
</script>