diff --git a/src/main/java/au/com/royalpay/payment/manage/merchantid/core/impl/MerchantIdManageServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchantid/core/impl/MerchantIdManageServiceImpl.java index 6a77ac270..0af53f8db 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchantid/core/impl/MerchantIdManageServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchantid/core/impl/MerchantIdManageServiceImpl.java @@ -62,8 +62,8 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService { @Override public Map> listSubMerchantId(JSONObject manager) { - List clients = clientMapper.listSubMerchantId(); - return getClientMap(clients); + List clients = clientMapper.listSubMerchantId(); + return getClientMap(clients); } @Override public JSONObject listNotTradeSubMerchantId(JSONObject manager) { @@ -139,7 +139,10 @@ public class MerchantIdManageServiceImpl implements MerchantIdManageService { client.put("temp_sub_merchant", true); } } - Map> clientsMap = clients.stream().filter(t->t.containsKey("merchant_id")).filter(t->t.containsKey("sub_merchant_id")).collect(Collectors.groupingBy(t->t.getString("merchant_id"))); + Map> clientsMap = clients.stream() + .filter(t->t.containsKey("merchant_id")) + .filter(t->t.containsKey("sub_merchant_id")) + .collect(Collectors.groupingBy(t->t.getString("merchant_id"))); return clientsMap; } diff --git a/src/main/ui/static/payment/merchantid/merchant_id_manager.js b/src/main/ui/static/payment/merchantid/merchant_id_manager.js index b184544da..fea7a0443 100644 --- a/src/main/ui/static/payment/merchantid/merchant_id_manager.js +++ b/src/main/ui/static/payment/merchantid/merchant_id_manager.js @@ -17,19 +17,61 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS }) }]); app.controller('merchantIdManageCtrl', ['$scope', '$state', '$http', function ($scope, $state, $http) { - $scope.isCollapsed = true; - $scope.toShow = false; - $scope.client_loading = true; + $scope.isCollapsed = true; + $scope.toShow = false; + $scope.client_loading = true; - $scope.loadClient = function () { + // 前端渲染的end索引 + $scope.endIndexMap = {}; + // 初始化索引是60 + const initEndIndex = 60; + $scope.loadClient = function () { $http.get('/sys/merchant_id').then(function (resp) { - $scope.clientsMap = resp.data; - $scope.client_loading = false; + $scope.clientsMap = resp.data; + $scope.client_loading = false; + + // 加入对应项的end索引值 + // 如果数据小于60,索引值为数据长度 + // 否则设置为60 + for (var key in $scope.clientsMap) { + $scope.endIndexMap[key] = initEndIndex; + var length = $scope.clientsMap[key].length; + if (length <= initEndIndex) + $scope.endIndexMap[key] = length; + + } }); }; - $scope.loadClient(); + $scope.loadClient(); + + /** + * 点击更多加载 + * 判断加60后的索引是否超出数组长度 + * @param key + */ + $scope.more = function(key) { + + var endIndex = $scope.endIndexMap[key] + initEndIndex; + $scope.endIndexMap[key] = endIndex; + + if (endIndex > $scope.clientsMap[key].length) { + $scope.endIndexMap[key] = $scope.clientsMap[key].length; + } - $scope.showClient = function (sub_merchant_id) { + }; + + /** + * 收起 + * @param key + */ + $scope.packup = function(key) { + $scope.endIndexMap[key] = initEndIndex; + var length = $scope.clientsMap[key].length; + if (length <= initEndIndex) + $scope.endIndexMap[key] = length; + }; + + $scope.showClient = function (sub_merchant_id) { if($scope.sub_merchant_id == sub_merchant_id){ return; } @@ -38,6 +80,7 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.sub_merchant_id = sub_merchant_id; }); }; + }]); app.controller('noTradeSubMerchantIdCtrl', ['$scope', '$state', '$http','$uibModal', function ($scope, $state, $http,$uibModal) { $scope.pagination = {}; diff --git a/src/main/ui/static/payment/merchantid/templates/merchant_id_manage.html b/src/main/ui/static/payment/merchantid/templates/merchant_id_manage.html index ab9bff83b..608e5bc56 100644 --- a/src/main/ui/static/payment/merchantid/templates/merchant_id_manage.html +++ b/src/main/ui/static/payment/merchantid/templates/merchant_id_manage.html @@ -78,44 +78,53 @@