Merge remote-tracking branch 'origin/master'

master
xxssyyyyssxx 2021-11-05 18:04:54 +08:00
commit 25849fa8df
17 changed files with 972 additions and 131 deletions

View File

@ -0,0 +1,137 @@
package cn.palmte.work.controller.backend;
import cn.palmte.work.bean.ResponseMsg;
import cn.palmte.work.model.ProcurementType;
import cn.palmte.work.service.ProcurementTypeService;
import cn.palmte.work.utils.Utils;
import cn.palmte.work.utils.excel.ExportUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Controller
@RequestMapping("/procurement/type")
public class ProcurementTypeController extends BaseController{
@Autowired
private ProcurementTypeService procurementTypeService;
/**
*
* @param keywords
* @param pageNumber
* @param pageSize
* @param model
* @return
*/
@RequestMapping("/list")
public String list(@RequestParam(value = "keywords",required = false) String keywords,
@RequestParam(value = PAGE_NUMBER, defaultValue = DEFAULT_PAGE_NUMBER) int pageNumber,
@RequestParam(value = PAGE_SIZE, defaultValue = DEFAULT_PAGE_SIZE) int pageSize,
Map<String, Object> model) {
model.put("keywords",keywords);
ConcurrentHashMap<String, String> searchInfo = getSearchInfo(keywords,model);
model.put("pager",procurementTypeService.list(searchInfo,pageNumber,pageSize));
return "/admin/procurement_type_list";
}
/**
*
* @param model
* @return
*/
@GetMapping(value = "/add")
public String add( Map<String, Object> model){
ProcurementType procurementType = new ProcurementType();
model.put("procurementTypeId",-1);
model.put("procurementType",procurementType);
return "/admin/procurement_type_input";
}
/**
*
*/
@RequestMapping("/edit")
public String edit(@RequestParam("id") int id, Map<String, Object> model) {
ProcurementType procurementType = procurementTypeService.findOne(id);
model.put("procurementTypeId",id);
model.put("procurementType", procurementType);
return "/admin/procurement_type_input";
}
/**
*
* @param procurementTypeId
* @param procurementType
* @param model
* @return
*/
@PostMapping(value = "/save")
public String save(@RequestParam("procurementTypeId") int procurementTypeId,
ProcurementType procurementType, Map<String, Object> model){
procurementTypeService.saveOtUpdate(procurementTypeId,procurementType);
return "redirect:/procurement/type/list";
}
/**
*
* @param ids
* @return
*/
@GetMapping(value = "/delete")
@ResponseBody
public ResponseMsg delete(@RequestParam("ids") String ids){
String[] deleteIds=ids.split("#%#");
boolean deleted = procurementTypeService.deleteByIDs(deleteIds);
ResponseMsg responseMsge=new ResponseMsg();
if(deleted){
responseMsge.setStatus(0);
responseMsge.setMsg("删除成功");
} else{
responseMsge.setStatus(1);
responseMsge.setMsg("删除失败");
}
return responseMsge;
}
/**
*
*/
@RequestMapping("/enableOrDisable")
@ResponseBody
public ResponseMsg enableOrDisable(@RequestParam("id") int id,
@RequestParam("status") int status, RedirectAttributes attr) {
boolean isSuccess = false;
try {
isSuccess = procurementTypeService.enableOrDisable(status, id);
} catch (Exception e) {
e.getMessage();
}
if (isSuccess) {
return ResponseMsg.buildSuccessMsg("操作成功");
} else {
return ResponseMsg.buildSuccessMsg("操作失败");
}
}
/**
*
*/
@RequestMapping("/export")
public void export(@RequestParam(value = "keywords",required = false) String keywords, HttpServletResponse httpServletResponse) throws IOException {
Map<String, String> searchInfo = getSearchInfo(keywords);
downloadHeader(httpServletResponse , Utils.generateExcelName("采购类型表"), "application/octet-stream");
String[] headers = {"采购类型名称","所属大类","创建人","创建时间"};
String[] exportColumns = {"name","category","createdBy","createdTime"};
ExportUtils.exportToExcel(headers, exportColumns, 1, 10000,
httpServletResponse.getOutputStream(), (pN, pS) -> procurementTypeService.list(searchInfo, pN, pS).getList());
}
}

View File

@ -1,44 +0,0 @@
package cn.palmte.work.controller.backend;
import cn.palmte.work.model.ProfitMarginConfig;
import cn.palmte.work.model.ProfitMarginConfigRepository;
import cn.palmte.work.service.ProfitMarginConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Map;
@Controller
@RequestMapping("/profitMarginConfig")
public class ProfitMarginConfigController extends BaseController{
@Autowired
private ProfitMarginConfigService profitMarginConfigService;
@Autowired
private ProfitMarginConfigRepository profitMarginConfigRepository;
/**
*
*/
@RequestMapping("/edit")
public String edit(Map<String, Object> model) {
ProfitMarginConfig profitMarginConfig = profitMarginConfigRepository.findOne(1);
model.put("profitMarginConfig", profitMarginConfig);
return "/admin/profit_marfin_config_input";
}
@PostMapping(value = "/save")
public String save(ProfitMarginConfig profitMarginConfig,Map<String, Object> model){
try {
profitMarginConfigService.saveOrUpdate(profitMarginConfig);
} catch (Exception e) {
model.put("errorMessage", e.getMessage());
return "/common/error";
}
return "redirect:/profitMarginConfig/edit";
}
}

View File

@ -0,0 +1,36 @@
package cn.palmte.work.controller.backend;
import cn.palmte.work.model.SysConfigRepository;
import cn.palmte.work.pojo.SysConfigRequest;
import cn.palmte.work.service.SysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Map;
@Controller
@RequestMapping("/sys/config")
public class SysConfigController extends BaseController{
@Autowired
private SysConfigService sysConfigService;
@Autowired
private SysConfigRepository sysConfigRepository;
@RequestMapping("/edit")
public String edit(Map<String, Object> model) {
model.put("underwrittenTaxRate",sysConfigRepository.findByCodeEquals("underwrittenTaxRate").getValue());
model.put("projectContributionProfitRateThreshold",sysConfigRepository.findByCodeEquals("projectContributionProfitRateThreshold").getValue());
return "admin/profit_marfin_config_input";
}
@RequestMapping("/save")
public String save(SysConfigRequest sysConfigRequest, Map<String, Object> model) {
sysConfigService.saveOrUpdate(sysConfigRequest);
return "redirect:/sys/config/edit";
}
}

View File

@ -0,0 +1,86 @@
package cn.palmte.work.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
*
*/
@Entity
@Table(name = "procurement_type")
public class ProcurementType {
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GenericGenerator(name = "persistenceGenerator", strategy = "increment")
private Integer id;
private String name;
private int category;
private int enabled;
@Column(name = "created_by")
private String createdBy;
/**
*
*/
@Column(name = "created_time")
@Temporal(TemporalType.TIMESTAMP)
private Date createdTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getCategory() {
return category;
}
public void setCategory(int category) {
this.category = category;
}
public int getEnabled() {
return enabled;
}
public void setEnabled(int enabled) {
this.enabled = enabled;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
}

View File

@ -0,0 +1,8 @@
package cn.palmte.work.model;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ProcurementTypeRepository extends JpaRepository<ProcurementType,Integer> {
}

View File

@ -1,51 +0,0 @@
package cn.palmte.work.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
/**
*
*/
@Entity
@Table(name = "profit_margin_config")
public class ProfitMarginConfig {
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GenericGenerator(name = "persistenceGenerator", strategy = "increment")
private Integer id;
@Column(name = "year_profit_margin")
private String yearProfitMargin;
@Column(name = "threshold_value")
private String thresholdValue;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getYearProfitMargin() {
return yearProfitMargin;
}
public void setYearProfitMargin(String yearProfitMargin) {
this.yearProfitMargin = yearProfitMargin;
}
public String getThresholdValue() {
return thresholdValue;
}
public void setThresholdValue(String thresholdValue) {
this.thresholdValue = thresholdValue;
}
}

View File

@ -1,7 +0,0 @@
package cn.palmte.work.model;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ProfitMarginConfigRepository extends JpaRepository<ProfitMarginConfig,Integer> {
}

View File

@ -0,0 +1,75 @@
package cn.palmte.work.model;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
/**
*
*/
@Entity
@Table(name = "sys_config")
public class SysConfig {
/**
* id
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@GenericGenerator(name = "persistenceGenerator", strategy = "increment")
private Integer id;
private String code;
private String name;
private String value;
/**
*
*/
@Column(name = "update_time")
@Temporal(TemporalType.TIMESTAMP)
private Date updateTime;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}

View File

@ -0,0 +1,9 @@
package cn.palmte.work.model;
import org.springframework.data.jpa.repository.JpaRepository;
public interface SysConfigRepository extends JpaRepository<SysConfig,Integer> {
SysConfig findByCodeEquals(String code);
}

View File

@ -0,0 +1,31 @@
package cn.palmte.work.pojo;
public class SysConfigRequest {
/**
* ()
*/
private String underwrittenTaxRate;
/**
*
*/
private String projectContributionProfitRateThreshold;
public String getUnderwrittenTaxRate() {
return underwrittenTaxRate;
}
public void setUnderwrittenTaxRate(String underwrittenTaxRate) {
this.underwrittenTaxRate = underwrittenTaxRate;
}
public String getProjectContributionProfitRateThreshold() {
return projectContributionProfitRateThreshold;
}
public void setProjectContributionProfitRateThreshold(String projectContributionProfitRateThreshold) {
this.projectContributionProfitRateThreshold = projectContributionProfitRateThreshold;
}
}

View File

@ -0,0 +1,84 @@
package cn.palmte.work.service;
import cn.palmte.work.model.ProcurementType;
import cn.palmte.work.model.ProcurementTypeRepository;
import cn.palmte.work.utils.InterfaceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.jfunc.common.db.QueryHelper;
import top.jfunc.common.db.bean.Page;
import top.jfunc.common.db.utils.Pagination;
import java.util.Date;
import java.util.Map;
@Service
public class ProcurementTypeService {
@Autowired
private ProcurementTypeRepository procurementTypeRepository;
@Autowired
private Pagination pagination;
public Page<ProcurementType> list(Map<String, String> searchInfo, int pageNumber, int pageSize){
QueryHelper queryHelper = new QueryHelper("SELECT *","procurement_type");
queryHelper.addCondition(searchInfo.containsKey("name"), "name like ?", "%" +
searchInfo.get("name") + "%");
queryHelper.addCondition(searchInfo.containsKey("category") && !"-1".equals(searchInfo.get("category")),
"category=" + searchInfo.get("category"));
queryHelper.addCondition(searchInfo.containsKey("enabled") && !"-1".equals(searchInfo.get("enabled")),
"enabled=" + searchInfo.get("enabled"));
queryHelper.addCondition(searchInfo.containsKey("startTime"), "created_time >= ?", searchInfo.get("startTime") + " 00:00:00");
queryHelper.addCondition(searchInfo.containsKey("endTime"), "created_time <= ?", searchInfo.get("endTime") + " 23:59:59");
queryHelper.addOrderProperty("created_time", false);
return pagination.paginate(queryHelper.getSql(), ProcurementType.class,pageNumber,pageSize);
}
public ProcurementType findOne(int id) {
return procurementTypeRepository.findOne(id);
}
public void saveOtUpdate(int procurementTypeId, ProcurementType procurementType) {
ProcurementType obj = procurementTypeRepository.findOne(procurementTypeId);
if(null == obj){
obj = new ProcurementType();
obj.setName(procurementType.getName());
obj.setCategory(procurementType.getCategory());
obj.setEnabled(procurementType.getEnabled());
obj.setCreatedBy(InterfaceUtil.getAdmin().getRealName());
obj.setCreatedTime(new Date());
}else {
obj.setName(procurementType.getName());
obj.setCategory(procurementType.getCategory());
obj.setEnabled(procurementType.getEnabled());
}
procurementTypeRepository.saveAndFlush(obj);
}
public boolean deleteByIDs(String[] deleteIds) {
boolean deleted = true;
try {
for (String id : deleteIds) {
procurementTypeRepository.delete(Integer.parseInt(id));
}
}catch (Exception e){
e.printStackTrace();
deleted = false;
}
return deleted;
}
public boolean enableOrDisable(int status, int id) {
ProcurementType one = procurementTypeRepository.findOne(id);
one.setEnabled(status);
ProcurementType procurementType = procurementTypeRepository.saveAndFlush(one);
if(null != procurementType){
return true;
}
return false;
}
}

View File

@ -1,21 +0,0 @@
package cn.palmte.work.service;
import cn.palmte.work.model.ProfitMarginConfig;
import cn.palmte.work.model.ProfitMarginConfigRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ProfitMarginConfigService {
@Autowired
private ProfitMarginConfigRepository profitMarginConfigRepository;
public void saveOrUpdate(ProfitMarginConfig profitMarginConfig) {
ProfitMarginConfig obj = profitMarginConfigRepository.findOne(1);
obj.setThresholdValue(profitMarginConfig.getThresholdValue());
obj.setYearProfitMargin(profitMarginConfig.getYearProfitMargin());
profitMarginConfigRepository.saveAndFlush(obj);
}
}

View File

@ -0,0 +1,30 @@
package cn.palmte.work.service;
import cn.palmte.work.model.SysConfig;
import cn.palmte.work.model.SysConfigRepository;
import cn.palmte.work.pojo.SysConfigRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
@Service
public class SysConfigService {
@Autowired
private SysConfigRepository sysConfigRepository;
public void saveOrUpdate(SysConfigRequest sysConfigRequest) {
SysConfig underwrittenTaxRate = sysConfigRepository.findByCodeEquals("underwrittenTaxRate");
underwrittenTaxRate.setValue(sysConfigRequest.getUnderwrittenTaxRate());
underwrittenTaxRate.setUpdateTime(new Date());
sysConfigRepository.saveAndFlush(underwrittenTaxRate);
SysConfig projectContributionProfitRateThreshold = sysConfigRepository.findByCodeEquals("projectContributionProfitRateThreshold");
projectContributionProfitRateThreshold.setValue(sysConfigRequest.getProjectContributionProfitRateThreshold());
projectContributionProfitRateThreshold.setUpdateTime(new Date());
sysConfigRepository.saveAndFlush(projectContributionProfitRateThreshold);
}
}

View File

@ -0,0 +1,49 @@
<#assign base=request.contextPath />
<#import "../common/defaultLayout.ftl" as defaultLayout>
<@defaultLayout.layout>
<style>
.am-icon-btn{
padding-top: 12px;
}
</style>
<div class="admin-content">
<div class="am-cf am-padding">
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">首页</strong> / <small>管理中心</small></div>
</div>
<div class="am-g">
<div class="am-u-sm-12">
<table class="am-table">
<tbody>
<tr>
<td class="am-primary" >用户名称:&nbsp;&nbsp;<span style="color:#5eb95e">${Session["realsName"]!""}</span></td>
<td class="am-primary">上次登录时间:&nbsp;&nbsp;<span style="color:#5eb95e">${Session["lastLoginTime"]!""}</span></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
})
</script>
</@defaultLayout.layout>

View File

@ -0,0 +1,104 @@
<#assign base=request.contextPath />
<#import "../common/defaultLayout.ftl" as defaultLayout>
<@defaultLayout.layout>
<link rel="stylesheet" href="${base}/assets/css/amazeui.switch.css"/>
<script type="text/javascript">
var base = '${base}';
</script>
<div class="admin-content">
<div class="admin-content-body">
<div class="am-cf am-padding">
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">配置管理</strong> /
<small>采购类型配置</small>
</div>
</div>
<form method="post" class="am-form" id="tmpForm"
action="${base}/procurement/type/save">
<input name="procurementTypeId" id="procurementTypeId" type="hidden" value="${procurementTypeId!}"/>
<div class="am-tabs am-margin" data-am-tabs>
<ul class="am-tabs-nav am-nav am-nav-tabs">
<li class="am-active"><a href="#tab1">新增/编辑</a></li>
</ul>
<div class="am-tabs-bd">
<div class="am-tab-panel am-fade am-in am-active" id="tab1">
<div class="am-g am-form-group am-margin-top" style="display: flex;">
<div class="am-u-sm-4 am-u-md-2 am-text-right">
<span style="color: red;">*</span>采购类型名称</div>
<div class="am-u-sm-6 am-u-md-6">
<input class="js-ajax-validate" name="name" data-validation-message="请输入告警类型名称20字符以内"
minlength="1" maxlength="20"
value="${procurementType.name!}" type="text" required/>
</div>
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
</div>
<div class="am-g am-form-group am-margin-top" style="display: flex;">
<div class="am-u-sm-4 am-u-md-2 am-text-right">
<span style="color: red;">*</span>所属大类</div>
<div class="am-u-sm-6 am-u-md-6">
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="category" name="category">
<option value="-1" >请选择所属大类</option>
<option value="1" <#if procurementType.category! ==1>selected</#if> >设备</option>
<option value="2" <#if procurementType.category! ==2>selected</#if> >服务</option>
<option value="3" <#if procurementType.category! ==3>selected</#if> >施工</option>
<option value="4" <#if procurementType.category! ==4>selected</#if> >其他</option>
</select>
</div>
<div class="am-u-sm-2 am-u-md-4 input-msg"></div>
</div>
<div class="am-g am-form-group am-margin-top">
<div class="am-u-sm-4 am-u-md-2 am-text-right">启用/禁用</div>
<div class="am-u-sm-12 am-u-md-4 switch-button" style="height: 25px;">
<input id="switch" name="switch" type="checkbox" data-size='xs'
data-am-switch data-off-text="禁用" data-on-text="启用"
<#if procurementType.enabled==1 >checked</#if>
/>
<input type="hidden" class="am-input-sm" name="enabled" id="enabled"
value="${procurementType.enabled!1}"/>
</div>
<div class="am-hide-sm-only am-u-md-1" style="color: red;"></div>
<div class="am-u-sm-2 am-u-md-5 input-msg"></div>
</div>
</div>
</div>
</div>
<!--选项卡tabsend-->
<div class="am-margin">
<button type="submit" id="submitBtn" class="am-btn am-btn-primary am-btn-xs">提交保存</button>
<button type="button" class="am-btn am-btn-warning am-btn-xs"
onclick="javascript:history.go(-1);">返回上一级
</button>
</div>
</form>
</div>
</div>
</@defaultLayout.layout>
<script src="${base}/common/jQuery-File-Upload/js/vendor/jquery.ui.widget.js"></script>
<script type="text/javascript" src="${base}/common/jQuery-File-Upload/js/jquery.iframe-transport.js"></script>
<script type="text/javascript" src="${base}/common/jQuery-File-Upload/js/jquery.fileupload.js"></script>
<script src="${base}/common/jQuery-File-Upload/js/jquery.fileupload-process.js"></script>
<script src="${base}/common/jQuery-File-Upload/js/jquery.fileupload-validate.js"></script>
<script src="${base}/assets/js/amazeui.switch.js"></script>
<script>
var $mycheckbox = $('.switch-button');
$mycheckbox.each(function () {
$("#switch").on({
'switchChange.bootstrapSwitch': function (event, state) {
if (state.toString() == "true") {
$("#enabled").val("1");
} else {
$("#enabled").val("0");
}
}
});
});
</script>

View File

@ -0,0 +1,314 @@
<#assign base=request.contextPath />
<#import "../common/defaultLayout.ftl" as defaultLayout>
<@defaultLayout.layout>
<link rel="stylesheet" href="${base}/assets/css/amazeui.switch.css"/>
<div class="admin-content">
<div class="am-cf am-padding" style="padding:1rem 1.6rem 1.6rem 1rem;margin:0px;">
<!-- padding:1px 2px 3px 4px;上、右、下,和左 -->
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">配置管理</strong> /
<small>采购类型配置</small>
</div>
</div>
<div class="am-g">
<div class="am-u-sm-12">
<form class="am-form" id="listForm" action="${base}/procurement/type/list" method="POST">
<input type="hidden" id="keywords" name="keywords" value='${keywords!""}'/>
<table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;">
<tbody>
<tr>
<th class="am-text-middle">类型名称</th>
<td>
<div class="am-u-sm-10">
<input type="text" id="name" class="am-form-field am-input-sm"
value="${name!}"/>
</div>
</td>
<th class="am-text-middle">所属大类</th>
<td>
<div class="am-u-sm-10">
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="category">
<option value="-1">全部</option>
<option value="1" <#if category! == "1">selected</#if> >设备</option>
<option value="2" <#if category! == "2">selected</#if> >服务</option>
<option value="3" <#if category! == "3">selected</#if> >施工</option>
<option value="4" <#if category! == "4">selected</#if> >其他</option>
</select>
</div>
</td>
</tr>
<tr>
<th class="am-text-middle">创建时间</th>
<td>
<div class="am-u-sm-10">
<div class="am-form am-form-inline">
<div class="am-form-group am-form-icon">
<i class="am-icon-calendar"></i>
<input type="text" class="am-form-field am-input-sm" id="startTime"
value="${startTime!}" placeholder="开始日期" data-am-datepicker>
</div>
<div class="am-form-group">至</div>
<div class="am-form-group am-form-icon">
<i class="am-icon-calendar"></i>
<input type="text" class="am-form-field am-input-sm" id="endTime"
value="${endTime!}"
placeholder="结束日期" data-am-datepicker>
</div>
</div>
</div>
</td>
<th class="am-text-middle">启用状态</th>
<td>
<div class="am-u-sm-10">
<select data-am-selected="{btnWidth: '40%', btnSize: 'sm'" id="enabled">
<option value="-1">全部</option>
<option value="1" <#if enabled! == "1">selected</#if> >启用</option>
<option value="0" <#if enabled! == "0">selected</#if> >禁用</option>
</select>
</div>
</td>
</tr>
<tr>
<td colspan="4">
<div align='right'>
<button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary"
id="submit-btn" onclick="sub_function('query')">搜索
</button>
<@shiro.hasPermission name="PROCTYPEEXPORT">
<button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary"
id="submit-btn-export" onclick="sub_function('export')">导出
</button>
</@shiro.hasPermission>
</div>
</td>
</tr>
</tbody>
</table>
</form>
</div>
<div class="am-btn-toolbar" style="padding-left:.5rem;">
<div class="am-btn-group am-btn-group-xs">
<@shiro.hasPermission name="PROCTYPEADD">
<button type="button" class="am-btn am-btn-default"
onclick="location.href='${base}/procurement/type/add'">
<span class="am-icon-plus"></span> 新增
</button>
</@shiro.hasPermission>
<@shiro.hasPermission name="PROCTYPEDEL">
<button type="button" id="deleteButton" disabled="disabled" class="am-btn am-btn-default"
onclick="deleteAll('${base}/procurement/type/delete')"><span
class="am-icon-trash-o"></span> 删除
</button>
</@shiro.hasPermission>
</div>
</div>
</div>
<div class="am-g">
<div class="am-u-sm-12">
<div class="am-scrollable-horizontal">
<table class="am-table am-table-striped am-table-hover table-main">
<thead>
<tr class="am-text-nowrap">
<th class="table-check"><input type="checkbox" id="allCheck"></th>
<th class="table-title">采购类型名称</th>
<th class="table-title">所属大类</th>
<th class="table-title">创建人</th>
<th class="table-title">创建时间</th>
<th class="table-title">操作</th>
</tr>
</thead>
<tbody>
<#if (pager.list)?exists && (pager.list?size>0)>
<#list pager.list as list>
<tr>
<td><input type="checkbox" name="ids" value="${list.id}"/></td>
<td>${list.name!}</td>
<td>${list.category!}</td>
<td>${list.createdBy!}</td>
<td><#if list.createdTime??>${list.createdTime?datetime}</#if></td>
<td>
<div id="edit-div" class="am-btn-toolbar switch-button">
<div class="am-btn-group am-btn-group-xs">
<@shiro.hasPermission name="PROCTYPEEDIT">
<button type="button"
class="am-btn am-btn-default am-btn-xs am-text-secondary"
onclick="location.href='${base}/procurement/type/edit?id=${list.id?c}'">
<span class="am-icon-pencil-square-o"></span>编辑
</button>
</@shiro.hasPermission>
<input id="${list.id}" type="checkbox" data-size='xs'
data-am-switch data-off-text="已禁用" data-on-text="已启用"
<#if list.enabled==1 >checked</#if>
/>
</div>
</div>
</td>
</tr>
</#list>
</#if>
</tbody>
</table>
</div>
<div class="am-cf">
<!-- 分页 -->
<#if (pager.list)?exists && (pager.list?size>0) >
<div class="am-fr">
<#include "../common/order_list_pager.ftl">
</div>
<#else>
<div class="am-kai" align="center">
<h3>没有找到任何记录!</h3>
</div>
</#if>
</div>
</div>
</div>
</div>
</@defaultLayout.layout>
<script src="${base}/assets/js/amazeui.switch.js"></script>
<script type="text/javascript">
var sub_function = function (type) {
initSearch();
if (type == 'export') {
$("#listForm").attr("action", "${base}/procurement/type/export");
} else {
$("#listForm").attr("action", "${base}/procurement/type/list");
}
$("#listForm").submit();
};
function initSearch() {
var keywordsObj = {};
if ($("#name").val())
keywordsObj.name = $("#name").val();
if ($("#category").val())
keywordsObj.category = $("#category").val();
if ($("#enabled").val())
keywordsObj.enabled = $("#enabled").val();
if ($("#startTime").val())
keywordsObj.startTime = $("#startTime").val();
if ($("#endTime").val())
keywordsObj.endTime = $("#endTime").val();
var keywords = "";
if (!$.isEmptyObject(keywordsObj)) {
keywords = JSON.stringify(keywordsObj);
}
console.log("keywords = " + keywords);
$("#keywords").val(keywords);
}
$(function () {
//为每个启用或禁用按钮增加事件
var $mycheckbox = $('.switch-button').find("input[type='checkbox']");
$mycheckbox.each(function () {
var myid = $(this).attr("id");
var prop = $(this).attr("prop");
$(this).on({
'switchChange.bootstrapSwitch': function (event, state) {
toggle(myid, state ? 1 : 0);
}
});
});
});
//启用或者禁用
var toggle = function (id, status) {
$.ajax({
url: "${base}/procurement/type/enableOrDisable",
data: {id: id, status: status},
type: "post",
dataType: "json",
async: false,
success: function (data) {
parent.layer.msg(data.msg);
}
});
};
$(function () {
$("body").on('click', '.list-item', function () {
$(".list-item").removeClass("tr-selected");
$(this).addClass('tr-selected');
});
$("#allCheck").click(function () {
$('input[name="ids"]').prop("checked", this.checked);
$("#deleteButton").prop("disabled", $("input[name='ids']:checked").length == 0 ? true : false);
});
var $citySubBox = $("input[name='ids']");
$citySubBox.click(function () {
$("#allCheckCity").prop("checked", $citySubBox.length == $("input[name='ids']:checked").length ? true : false);
$("#deleteButton").prop("disabled", $("input[name='ids']:checked").length == 0 ? true : false);
});
var keywordsObj = {};
$("#submit-btn").on("click", function () {
if ($("#name").val())
keywordsObj.name = $("#name").val();
if ($("#category").val())
keywordsObj.category = $("#category").val();
if ($("#enabled").val())
keywordsObj.enabled = $("#enabled").val();
if ($("#startTime").val())
keywordsObj.startTime = $("#startTime").val();
if ($("#endTime").val())
keywordsObj.endTime = $("#endTime").val();
var keywords = "";
if (!$.isEmptyObject(keywordsObj)) {
keywords = JSON.stringify(keywordsObj);
}
$("#keywords").val(keywords);
$("#listForm").submit();
});
});
// 删除
var deleteAll = function (url) {
var $deleteButton = $("#deleteButton");// 删除按钮
var ids = "";
$("input[name='ids']:checked").each(function () {
ids += $(this).val() + "#%#";
});
var params = {ids: ids};
if (window.confirm('确定要删除吗?')) {
$.ajax({
url: url,
data: params,
dataType: "json",
async: false,
beforeSend: function (data) {
$deleteButton.prop("disabled", true)
},
success: function (data) {
$deleteButton.prop("disabled", false)
if (data.status == 0) {
alert("删除成功");
window.location.href = window.location.href;
} else if (data.status == 1) {
alert("删除失败");
}
}
});
}
}
</script>

View File

@ -7,9 +7,10 @@
<div class="admin-content">
<div class="admin-content-body">
<div class="am-cf am-padding">
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">配置管理</strong> /项目利润率配置</div>
<div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">配置管理</strong> /
<small>项目利润率配置</small></div>
</div>
<form method="post" class="am-form" id="tmpForm" action="${base}/profitMarginConfig/save">
<form method="post" class="am-form" id="tmpForm" action="${base}/sys/config/save">
<!--选项卡tabsbegin-->
<div class="am-tabs am-margin" data-am-tabs>
<ul class="am-tabs-nav am-nav am-nav-tabs">
@ -28,10 +29,10 @@
项目贡献利润率阀值:
</div>
<div class="am-u-sm-6 am-u-md-6">
<input name="thresholdValue" class="js-ajax-validate"
<input name="projectContributionProfitRateThreshold" class="js-ajax-validate"
data-validate-async data-validation-message="请输入项目贡献利润率阀值"
type="number" step="0.01" id="thresholdValue"
value="${profitMarginConfig.thresholdValue!}" minlength="1"
type="number" step="0.01" id="projectContributionProfitRateThreshold"
value="${projectContributionProfitRateThreshold!}" minlength="1"
maxlength="4" oninput="if(value.length>4)value=value.slice(0,4)"
placeholder="请输入项目贡献利润率阀值" required/>
<p>注:请注意保留小数点后两位</p>
@ -45,10 +46,10 @@
项目年利润率:
</div>
<div class="am-u-sm-6 am-u-md-6">
<input name="yearProfitMargin" class="js-ajax-validate"
<input name="underwrittenTaxRate" class="js-ajax-validate"
data-validate-async data-validation-message="请输入项目年利润率"
type="number" step="0.01" id="yearProfitMargin"
value="${profitMarginConfig.yearProfitMargin!}" minlength="1"
type="number" step="0.01" id="underwrittenTaxRate"
value="${underwrittenTaxRate!}" minlength="1"
maxlength="4" oninput="if(value.length>4)value=value.slice(0,4)"
placeholder="请输入项目年利润率" required/>
<p>注:请注意保留小数点后两位</p>