TestCtrl.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. define([ 'app/app' ], function(app) {
  2. app.register.controller('TestCtrl', ['$scope', '$http', 'ngTableParams', 'BrandsSubmit', 'BaseService', '$stateParams', '$timeout', function($scope, $http, ngTableParams, BrandsSubmit, BaseService, $stateParams, $timeout) {
  3. /**
  4. * description 这是用来数据初始化的,别删除
  5. * author 陈昊
  6. * date 2016年4月1日15:28:50
  7. */
  8. $scope.uploadKinds = function(){
  9. path_kinds = "static/js/test/kind.json"
  10. $http.get(path_kinds).success(function(data){
  11. str_kinds = angular.toJson(data);
  12. $http.post("product/kind/init", str_kinds).success(function(data){
  13. }).error(function(){
  14. });
  15. }).error(function(){
  16. });
  17. }
  18. $scope.uploadBrands = function(){
  19. path_brand = "static/js/test/brand.json"
  20. $http.get(path_brand).success(function(data){
  21. str_brands = angular.toJson(data)
  22. $http.post("product/init/brand", str_brands).success(function(data){
  23. }).error(function(){
  24. });
  25. }).error(function(){
  26. });
  27. }
  28. $scope.uploadProperty = function(){
  29. path_property = "static/js/test/property.json"
  30. $http.get(path_property).success(function(data){
  31. str_property = angular.toJson(data)
  32. $http.post("product/init/property", str_property).success(function(data){
  33. }).error(function(){
  34. });
  35. }).error(function(){
  36. });
  37. }
  38. $scope.uploadComponent = function(componentFileCount){
  39. for(var i = 0; i < componentFileCount; i++){
  40. filePath = "static/js/test/component" + i + ".json"
  41. $http.get(filePath).success(function(data){
  42. str_propertyvalue = angular.toJson(data);
  43. $http.post("product/init/component", str_propertyvalue).success(function(data){
  44. }).error(function(){
  45. });
  46. }).error(function(){
  47. });
  48. }
  49. }
  50. $scope.uploadPropertyValues = function(brandFileCount){
  51. for(var i = 0; i < brandFileCount; i++){
  52. filePath = "static/js/test/propertyvalue" + i + ".json"
  53. $http.get(filePath).success(function(data){
  54. str_propertyvalue = angular.toJson(data);
  55. $http.post("product/init/propertyvalue", str_propertyvalue).success(function(data){
  56. }).error(function(){
  57. });
  58. }).error(function(){
  59. });
  60. //为了防止浏览器卡死,这里需要休息一下下
  61. $timeout(function() {console.log("休息一下", i);}, 30000);
  62. }
  63. }
  64. }]);
  65. });