|
@@ -1,6 +1,6 @@
|
|
|
define([ 'app/app' ], function(app) {
|
|
define([ 'app/app' ], function(app) {
|
|
|
'use strict';
|
|
'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';
|
|
$rootScope.active = 'vendor_deliveryRule';
|
|
|
// $scope.tab = 'deliverRule';
|
|
// $scope.tab = 'deliverRule';
|
|
|
$scope.title = '新增配送规则';
|
|
$scope.title = '新增配送规则';
|
|
@@ -72,6 +72,19 @@ define([ 'app/app' ], function(app) {
|
|
|
};
|
|
};
|
|
|
initData();
|
|
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) {
|
|
$scope.addQtyFare = function (data) {
|
|
|
var fare = {
|
|
var fare = {
|
|
|
start : data.end,
|
|
start : data.end,
|
|
@@ -202,47 +215,50 @@ define([ 'app/app' ], function(app) {
|
|
|
$scope.cancel = function () {
|
|
$scope.cancel = function () {
|
|
|
$scope.chooseBox = false;
|
|
$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.chooseAddress = function () {
|
|
|
$scope.chooseBox = true;
|
|
$scope.chooseBox = true;
|
|
|
function getData() {
|
|
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();
|
|
getData();
|
|
|
}
|
|
}
|
|
|
}]);
|
|
}]);
|
|
|
-// 地区选择
|
|
|
|
|
|
|
+ // 地区选择
|
|
|
app.register.factory('TreeData', function () {
|
|
app.register.factory('TreeData', function () {
|
|
|
return function (tree) {
|
|
return function (tree) {
|
|
|
var me = this;
|
|
var me = this;
|