Browse Source

为图表数据添加权限认证功能

lwx_dev
erdanergou 2 years ago
parent
commit
bbf6d898ff
  1. 26
      src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java
  2. 4
      src/main/resources/templates/pages/material/material-view_back.html

26
src/main/java/com/dreamchaser/depository_manage/controller/DepositoryRecordController.java

@ -2307,7 +2307,7 @@ public class DepositoryRecordController {
* @param jsonObject 带查询数据
*/
@PostMapping("/getApplicationForMaterial")
public RestResponse getInventoryApplication(@RequestBody JSONObject jsonObject) {
public RestResponse getInventoryApplication(@RequestBody JSONObject jsonObject, HttpServletRequest request) {
Integer id = jsonObject.getInteger("id");
// 获取当前物料的库存数据
Inventory inventoryById = materialService.findInventoryById(id);
@ -2395,19 +2395,33 @@ public class DepositoryRecordController {
Map<String, Object> countItemForInventory = depositoryRecordService.createStackedAreaChartSeriesItem("count", inventoryCountList);
Map<String, Object> amountItemForInventory = depositoryRecordService.createStackedAreaChartSeriesItem("amount", inventoryAmountList);
Map<String, Object> result = new HashMap<>();
result.put("amountItemForIn", amountItemForIn);
result.put("countItemForIn", countItemForIn);
result.put("amountItemForOut", amountItemForOut);
result.put("countItemForOut", countItemForOut);
Map<String, List<String>> legendItem = new HashMap<>();
List<String> legends = new ArrayList<>();
legends.add("count");
legends.add("amount");
legendItem.put("data", legends);
result.put("legend", legendItem);
result.put("dayNames", dayNames);
result.put("countItemForInventory", countItemForInventory);
result.put("amountItemForInventory", amountItemForInventory);
String userAgent = request.getHeader("user-agent");
String token = request.getHeader("user-token");
if (token == null) {
token = (String) request.getSession().getAttribute("userToken");
}
UserByPort userToken = AuthenticationTokenPool.getUserToken(token);
if (PublicConfig.roleAdminorgList.contains(userToken.getMaindeparment())) {
result.put("amountItemForInventory", amountItemForInventory);
result.put("amountItemForOut", amountItemForOut);
result.put("amountItemForIn", amountItemForIn);
legends.add("amount");
}
result.put("legend", legendItem);
return new RestResponse(result);
}

4
src/main/resources/templates/pages/material/material-view_back.html

@ -171,7 +171,7 @@
<script type="text/html" id="quantityItem">
<span class="layui-badge-rim" id="quantity{{d.id}}" style="margin-right: 10px;">库存数:{{d.materialAndPlaceList[0].inventory}}</span>
<span class="layui-badge-rim" id="amount{{d.id}}" style="margin-right: 10px;">总金额:{{d.materialAndPlaceList[0].amount}}</span>
<span th:style="'display:'+${display == 'block' ? 'inline':'none'}" class="layui-badge-rim" id="amount{{d.id}}" style="margin-right: 10px;">总金额:{{d.materialAndPlaceList[0].amount}}</span>
</script>
<script src="/static/lib/layui-v2.8.6/layui.js" charset="utf-8"></script>
@ -247,7 +247,7 @@
title: '计量单位',
templet: '#unitItemList',
},
{field: 'place', width: 100, title: '所处库位', templet: '#placeItemList'},
{field: 'place', width: 150, title: '所处库位', templet: '#placeItemList'},
{title: '库存数', width: 230, templet: '#quantityItem', align: "center"},
{field: 'remark', width: 150, title: '备注'},
{title: '操作', width: 150, toolbar: '#currentTableBar', align: "center"},

Loading…
Cancel
Save