exchangeRate.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. define(['app/app'], function(app) {
  2. 'use strict';
  3. app.register.controller('exchangeRateCtrl', ['$scope', 'exchangeRateService', 'toaster', function($scope, exchangeRateService, toaster) {
  4. $scope.edit = false;
  5. exchangeRateService.getUSD(null, function(date) {
  6. $scope.usdExchangeRate = date.data;
  7. }, function(response) {
  8. toaster.pop('error', '获取信息失败:' + response.data);
  9. });
  10. $scope.save = function() {
  11. if ($scope.usdExchangeRate.fromCurrency == null || $scope.usdExchangeRate.fromCurrency == '') {
  12. $scope.usdExchangeRate.fromCurrency = 'USD';
  13. $scope.usdExchangeRate.toCurrency = 'RMB';
  14. $scope.usdExchangeRate.type = 'USD';
  15. }
  16. exchangeRateService.save(null, $scope.usdExchangeRate, function(data) {
  17. $scope.usdExchangeRate = data.data;
  18. $scope.edit = false;
  19. toaster.pop('success', '保存成功');
  20. }, function(response) {
  21. toaster.pop('error', '保存信息失败:' + response.data);
  22. });
  23. };
  24. $scope.modify = function() {
  25. $scope.edit = true;
  26. };
  27. $scope.cancle = function() {
  28. $scope.edit = false;
  29. }
  30. }]);
  31. });