123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- var editBuildingCtrl = function ($scope, $http, $filter, $loading) {
- $scope.params = editBuildingModal.params;
- $scope.parentLoad = editBuildingModal.parentLoad;
- $scope.dataModel = {};
- $scope.floorList = [];
- $scope.loadData = function () {
- $loading.show();
- $http({
- method: "get",
- url: "../../api/build/building/GetBuildingById",
- params: {
- buildingId: $scope.params.buildingId
- }
- }).then(function (result) {
- $loading.hide();
- $scope.dataModel = result.data.Data;
-
- }, function (resp) {
- $loading.hide();
- $scope.showMsg('错误', '服务器错误');
- });
- }
- $scope.getFloorList = function () {
- $http({
- method: "get",
- url: "../../api/build/building/GetFloorList",
- params: {
- buildingId: $scope.params.buildingId
- }
- }).then(function (result) {
- $scope.floorList = result.data.Data;
- }, function (resp) {
- });
- };
- $scope.add = function () {
- $scope.floorList.push({Name:""});
- };
- $scope.delete = function (index) {
- var floor = $scope.floorList[index];
- if (floor.BuildingFloorId) {
- $http.post('../../api/build/building/DeleteFloor', { buildingFloorId: floor.BuildingFloorId }).then(function (res) {
- if (res.data.IsSuccess) {
- $scope.floorList.splice(index, 1);
- } else {
- $scope.showMsg('错误', res.data.Message);
- }
- });
- }
- else {
- $scope.floorList.splice(index, 1);
- }
-
- };
- $scope.save = function (isflag) {
- if (!isflag) {
- $scope.showMsg('提示', '请填写相关信息');
- return false;
- }
- if (isflag) {
- $loading.show();
- $http({
- method: "post",
- url: "../../api/build/building/SaveBuilding",
- data: {
- data: $scope.dataModel,
- floorList: $scope.floorList,
- }
- }).then(function (result) {
- $loading.hide();
- if (result.data.IsSuccess) {
- $scope.showMsg('成功', "操作成功!");
-
- $scope.parentLoad();
- $scope.$hide();
- } else {
- $scope.showMsg('失败', result.data.Message);
- }
- }, function (resp) {
- $loading.hide();
- $scope.showMsg('错误', '服务器错误,' + resp.data.message);
- })
- }
- };
- $scope.invalidFee = function (index, form1, name) {
- if (form1 != undefined) {
- name = name + "_" + index;
- eval('var i=form1.' + name + '.$invalid');
- return i;
- }
- };
- $scope.loadData();
- $scope.getFloorList();
- };
- //定义模态框
- var editBuildingModal;
|