Sfoglia il codice sorgente

配送规则添加地区选择

hulh 9 anni fa
parent
commit
11cc8d3a31

+ 50 - 34
src/main/webapp/resources/js/vendor/controllers/forstore/vendor_deliveryRule_add_ctrl.js

@@ -1,6 +1,6 @@
 define([ 'app/app' ], function(app) {
     'use strict';
-    app.register.controller('vendorDeliveryRuleAddCtrl', ['$scope', '$rootScope', '$stateParams', 'Enterprise', 'toaster', 'DistributionRule', '$state', function ($scope, $rootScope, $stateParams, Enterprise, toaster, DistributionRule, $state) {
+    app.register.controller('vendorDeliveryRuleAddCtrl', ['$scope', '$rootScope', '$stateParams', 'Enterprise', 'toaster', 'DistributionRule', '$state', '$http', 'TreeData', function ($scope, $rootScope, $stateParams, Enterprise, toaster, DistributionRule, $state, $http, TreeData) {
         $rootScope.active = 'vendor_deliveryRule';
         // $scope.tab = 'deliverRule';
         $scope.title = '新增配送规则';
@@ -72,6 +72,19 @@ define([ 'app/app' ], function(app) {
         };
         initData();
 
+        $scope.loadCityData = function () {
+            $http.get('static/js/prod/data/city.json').success(function (data) {
+                var time1 = new Date().getTime();
+                $scope.cityData = convert(data);
+                var time2 = new Date().getTime();
+                console.log(time1+"=="+time2);
+                console.log(time2-time1);
+            }).error(function (res) {
+                console.log(res);
+            });
+        };
+        $scope.loadCityData();
+
         $scope.addQtyFare = function (data) {
             var fare = {
                 start : data.end,
@@ -202,47 +215,50 @@ define([ 'app/app' ], function(app) {
         $scope.cancel = function () {
             $scope.chooseBox = false;
         };
+        /**
+         * 将本地地址数据转化为可用的结构
+         * @param item
+         * @returns {Array}
+         */
+        function convert(item) {
+            var arr = [];
+            if(angular.isArray(item)) {
+                angular.forEach(item, function (v) {
+                    arr.push({
+                        label: v
+                    })
+                })
+            } else {
+                angular.forEach(item, function (v, k) {
+                    arr.push({
+                        label: k,
+                        items: convert(v),
+                        folded: true
+                    })
+                })
+            }
+            return arr;
+        }
         // 选择地区
         $scope.chooseAddress = function () {
             $scope.chooseBox = true;
             function getData() {
-                $http.get('static/js/prod/data/city.json').success(function (data) {
-                    console.log(convert(data));
-                    $scope.tree = new TreeData(convert(data));
-                }).error(function (res) {
-                    console.log(res);
-                });
+                var time1 = new Date().getTime();
+                $scope.tree = new TreeData($scope.cityData);
+                var time2 = new Date().getTime();
+                console.log(time1+"=="+time2);
+                console.log(time2-time1);
+                // $http.get('static/js/prod/data/city.json').success(function (data) {
+                //     // console.log(convert(data));
+                //     $scope.tree = new TreeData(convert(data));
+                // }).error(function (res) {
+                //     console.log(res);
+                // });
             }
-
-            /**
-             * 将本地地址数据转化为可用的结构
-             * @param item
-             * @returns {Array}
-             */
-            function convert(item) {
-                var arr = []
-                if(angular.isArray(item)) {
-                    angular.forEach(item, function (v) {
-                        arr.push({
-                            label: v
-                        })
-                    })
-                } else {
-                    angular.forEach(item, function (v, k) {
-                        arr.push({
-                            label: k,
-                            items: convert(v),
-                            folded: true
-                        })
-                    })
-                }
-                return arr;
-            }
-
             getData();
         }
     }]);
-// 地区选择
+    // 地区选择
     app.register.factory('TreeData', function () {
         return function (tree) {
             var me = this;

+ 10 - 6
src/main/webapp/resources/view/vendor/forstore/vendor_delivery_add_rule.html

@@ -425,9 +425,13 @@
 		font-size: 18px;
 		position: relative;
 		top: 3px;
-		right: 3px;
+		right: 0;
 		color: #ff8522;
 	}
+	.choose-box .tree ul i.fa-fw{
+		width: 1em;
+	}
+
 	.choose-box .tree ul div.check-1{
 		float: right;
 	}
@@ -550,8 +554,8 @@
 								<ul>
 									<li ng-repeat="address in tree.$data">
 										<div>
-											<i class="fa" ng-class="address.folded?'fa-caret-right':'fa-caret-down'" ng-click="tree.toggleFold(address)"></i>
-											<span ng-bind="address.label"></span><em>(1)</em>
+											<i class="fa fa-fw" ng-class="address.folded?'fa-caret-right':'fa-caret-down'" ng-click="tree.toggleFold(address)"></i>
+											<span ng-bind="::address.label"></span><em>(1)</em>
 											<div class="check-1">
 												<label class="check-act" ng-class="{'intermediate': tree.isSemiChecked(address)}">
 													<input type="checkbox" ng-model="address.checked" ng-change="tree.check(address)"  id="{{address.label}}">
@@ -562,8 +566,8 @@
 										<ul ng-hide="address.folded">
 											<li ng-repeat="city in address.items">
 												<div>
-													<i ng-if="city.items" class="fa" ng-class="city.folded?'fa-caret-right':'fa-caret-down'" ng-click="tree.toggleFold(city)"></i>
-													<span ng-bind="city.label"></span><em>(1)</em>
+													<i ng-if="city.items" class="fa fa-fw" ng-class="city.folded?'fa-caret-right':'fa-caret-down'" ng-click="tree.toggleFold(city)"></i>
+													<span ng-bind="::city.label"></span><em>(1)</em>
 													<div class="check-1">
 														<label class="check-act" ng-class="{'intermediate': tree.isSemiChecked(city)}" >
 															<input type="checkbox" ng-model="city.checked" ng-change="tree.check(city)" id="{{city.label}}">
@@ -574,7 +578,7 @@
 												<ul ng-hide="city.folded">
 													<li ng-repeat="area in city.items">
 															<label style="width: 100%;">
-																<span ng-bind="area.label"></span>
+																<span ng-bind="::area.label"></span>
 																	<div class="check-1">
 																	<label class="check-act">
 																		<input type="checkbox" ng-model="area.checked" ng-change="tree.check(area)" id="{{area.label}}">