From 16d881bca179993bee7f55ddae067aa056cb66fa Mon Sep 17 00:00:00 2001 From: hellolujian <1370256381@qq.com> Date: Fri, 24 Aug 2018 10:13:32 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=E5=95=86=E6=88=B7=E5=8F=B7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E9=A1=B5=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/merchantid/merchant_id_manager.js | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) 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 7d79b3c64..fea7a0443 100644 --- a/src/main/ui/static/payment/merchantid/merchant_id_manager.js +++ b/src/main/ui/static/payment/merchantid/merchant_id_manager.js @@ -21,7 +21,9 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.toShow = false; $scope.client_loading = true; + // 前端渲染的end索引 $scope.endIndexMap = {}; + // 初始化索引是60 const initEndIndex = 60; $scope.loadClient = function () { $http.get('/sys/merchant_id').then(function (resp) { @@ -29,31 +31,44 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.client_loading = false; // 加入对应项的end索引值 - for (var k in $scope.clientsMap) { - var length = $scope.clientsMap[k].length; - if (length <= initEndIndex) { - $scope.endIndexMap[k] = length; - } - else - $scope.endIndexMap[k] = initEndIndex; + // 如果数据小于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(); + /** + * 点击更多加载 + * 判断加60后的索引是否超出数组长度 + * @param key + */ $scope.more = function(key) { var endIndex = $scope.endIndexMap[key] + initEndIndex; - // 判断加60后的索引是否超出数组长度 + $scope.endIndexMap[key] = endIndex; + if (endIndex > $scope.clientsMap[key].length) { $scope.endIndexMap[key] = $scope.clientsMap[key].length; } - else - $scope.endIndexMap[key] = endIndex; + }; + /** + * 收起 + * @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) {