baimeng %!s(int64=9) %!d(string=hai) anos
pai
achega
974bc47bc6

BIN=BIN
wl/platforms/android/.gradle/2.2.1/taskArtifacts/cache.properties.lock


BIN=BIN
wl/platforms/android/.gradle/2.2.1/taskArtifacts/fileSnapshots.bin


BIN=BIN
wl/platforms/android/.gradle/2.2.1/taskArtifacts/taskArtifacts.bin


+ 21 - 8
wl/platforms/android/assets/www/js/controllers/my.js

xqd xqd
@@ -160,10 +160,12 @@
         }
         $scope.load(true);
     }]);
-    app.controller('myTruckAddCtrl', ['$scope', 'myService', 'msg', '$state', '$stateParams', 'camera', 'config', function ($scope, myService, msg, $state, $stateParams, camera, config) {
+    app.controller('myTruckAddCtrl', ['$scope', 'myService', 'msg', '$state', '$stateParams', 'camera', 'config', '$timeout', function ($scope, myService, msg, $state, $stateParams, camera, config, $timeout) {
         $scope.vm = {};
         if ($stateParams.item) {
             $scope.vm = $stateParams.item;
+            $scope.vm.begin_use_date = new Date($scope.vm.begin_use_date);
+            $scope.vm.expire_date = new Date($scope.vm.expire_date);
         }
         $scope.typeOpt = [
             { name: '厢式货车', value: '1' },
@@ -188,13 +190,24 @@
         { name: '其他', value: '20' }];
         $scope.save = function () {
             msg.loading('保存中...');
-            myService.addTruck($scope.vm).then(function (result) {
-                msg.hide();
-                $state.go('wl.my_truck');
-            }, function (erro) {
-                msg.hide();
-                msg.error(erro.data.message);
-            });
+            if ($scope.vm.id>0) {
+                myService.updateTruck($scope.vm).then(function (result) {
+                    msg.hide();
+                    $state.go('wl.my_truck');
+                }, function (erro) {
+                    msg.hide();
+                    msg.error(erro.data.message);
+                });
+            } else {
+                myService.addTruck($scope.vm).then(function (result) {
+                    msg.hide();
+                    $state.go('wl.my_truck');
+                }, function (erro) {
+                    msg.hide();
+                    msg.error(erro.data.message);
+                });
+            }
+         
         }
         //上传图片
         $scope.setPhoto = function () {

+ 21 - 8
wl/www/js/controllers/my.js

xqd xqd
@@ -160,10 +160,12 @@
         }
         $scope.load(true);
     }]);
-    app.controller('myTruckAddCtrl', ['$scope', 'myService', 'msg', '$state', '$stateParams', 'camera', 'config', function ($scope, myService, msg, $state, $stateParams, camera, config) {
+    app.controller('myTruckAddCtrl', ['$scope', 'myService', 'msg', '$state', '$stateParams', 'camera', 'config', '$timeout', function ($scope, myService, msg, $state, $stateParams, camera, config, $timeout) {
         $scope.vm = {};
         if ($stateParams.item) {
             $scope.vm = $stateParams.item;
+            $scope.vm.begin_use_date = new Date($scope.vm.begin_use_date);
+            $scope.vm.expire_date = new Date($scope.vm.expire_date);
         }
         $scope.typeOpt = [
             { name: '厢式货车', value: '1' },
@@ -188,13 +190,24 @@
         { name: '其他', value: '20' }];
         $scope.save = function () {
             msg.loading('保存中...');
-            myService.addTruck($scope.vm).then(function (result) {
-                msg.hide();
-                $state.go('wl.my_truck');
-            }, function (erro) {
-                msg.hide();
-                msg.error(erro.data.message);
-            });
+            if ($scope.vm.id>0) {
+                myService.updateTruck($scope.vm).then(function (result) {
+                    msg.hide();
+                    $state.go('wl.my_truck');
+                }, function (erro) {
+                    msg.hide();
+                    msg.error(erro.data.message);
+                });
+            } else {
+                myService.addTruck($scope.vm).then(function (result) {
+                    msg.hide();
+                    $state.go('wl.my_truck');
+                }, function (erro) {
+                    msg.hide();
+                    msg.error(erro.data.message);
+                });
+            }
+         
         }
         //上传图片
         $scope.setPhoto = function () {

+ 7 - 0
wl/www/js/services/myservice.js

xqd
@@ -16,6 +16,13 @@
                     data: model
                 })
             },
+            updateTruck: function (model) {
+                return $http({
+                    url: config.server + 'api/trucks/'+model.id,
+                    method: "post",
+                    data: model
+                })
+            },
             deleteTruck:function (id) {
                 return $http({
                     url: config.server + 'api/trucks/' + id,

+ 1 - 1
wl/www/templates/my/truck-add.html

xqd
@@ -17,7 +17,7 @@
                 <span class="input-label">
                     类型<span class="mustfill">*</span>
                 </span>
-                <select ng-model="vm.type" ng-options="x.value as x.name for x in typeOpt"></select>
+                <select ng-model="vm.type" ng-options="x.type as x.name for x in typeOpt"></select>
             </label>
             <label class="item item-input ">
                 <span class="input-label">车牌号<span class="mustfill">*</span></span>