supplyStoreRoom.js 2.87 KB
(function () {
    "use strict";
    var supplychainStoreRoomSupplyIndexCtrl = function ($scope, $modal, $http, customizationService, dialogService) {
        $scope.$emit('navShow', 2);
        //初始化,关键字
        $scope.vm = {
            pageNumber: 1,
            pageSize: 10,
            isActive: true,
            totalCount: 0
        };
        $scope.page = {
            pageSize: 10,
            pageNumber: 1
        };
        //获取供应链
        $scope.networks = [];
        $scope.getSupplychainNetworkList = function () {
            customizationService.apiCustomizationSupplyFindSupplychainNetwork({pageSize: 0,demandIsActive:true, supplyIsActive:true}).success(function (data) {
                if (data.errors == null || data.errors.length > 0) {
                    dialogService.tip(data.errors);
                } else {
                    angular.forEach(data.result, function (network) {
                        network.showOperatingUnitName = network.supplyTenantName + "  ——  " + network.demandTenantName;
                        $scope.networks.push(network);
                    });
                }
            });
        };
        //列表 数生成
        $scope.getSupplychainNetworkList();

        $scope.getList = function () {
            if ($scope.vm.network == null) {
                dialogService.tip([{message: "请选择供应链"}]);
            } else {
                $scope.vm.supplychainNetworkId = $scope.vm.network.id;
                customizationService.apiCustomizationSupplychainStoreRoomSupplyFind($scope.vm).success(function (data) {
                    if (data.errors == null || data.errors.length > 0) {
                        dialogService.tip(data.errors);
                    } else {
                        $scope.vm.totalCount = data.totalCount;

                        if (data.result != null && data.result.length > 0) {
                            var parentIndex = 0;
                            angular.forEach(data.result, function (result) {
                                if (parentIndex % 2 == 0) {
                                    result.color = "color-blue";
                                } else {
                                    result.color = "color-yellow";
                                }
                                parentIndex++;
                                result.level = 0;
                                result.visable = true;
                            });
                        }
                        $scope.trees = data.result;
                    }
                });
            }
        };

        $scope.doSearch = function () {
            $scope.getList();
        };
    };


    angular.module("xn.page", [])
        .controller("SupplychainStoreRoomSupplyIndexCtrl", ["$scope", "$modal", "$http", "CustomizationService", "dialogService", supplychainStoreRoomSupplyIndexCtrl])
})();