demandRoom.js 3.41 KB
(function () {
    "use strict";

    //需求方物料主页
    var  demandRoomIndexController = function ($scope,dialogService,CustomizationService) {

        //分页传入的数值
        $scope.vm ={
            pageNumber:1,
            pageSize:10
        };


        //拉取开放物料
        $scope.openRoomList = [];

        $scope.getOpenRoomList = function () {
            CustomizationService.apiCustomizationSupplyChainOpenRoomFind($scope.vm).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    $scope.openRoomList = data.result;
                    $scope.vm.totalCount = data.totalCount;
                }
            })
        }

        $scope.doSearch = function () {
            CustomizationService.apiCustomizationSupplyChainopenRoomSearch($scope.vm).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    $scope.openRoomList = data.result;
                    $scope.vm.totalCount = data.totalCount;
                }
            })
        }

        //导入
        $scope.import = {
            title:"导入",
            uploadMethod:"api.customization.supplychain.open.room.upload",
            downLoadUrl:"/customization/api.do",
            downLoadMethod:"api.supplychain.open.room.template"
        };

        $scope.getOpenRoomList();
        //导出
        $scope.doExceport = function () {
            CustomizationService.apiCustomizationSupplyChainOpenRoomExport($scope.vm).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    window.open(data.url, "_self");
                }
            })
        };

        //失效
        $scope.inactive = function (openRoom) {
            CustomizationService.apiCustomizationSupplyChainopenRoomInactive({id:openRoom.id,rowVersion:openRoom.rowVersion}).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    $scope.getOpenRoomList();
                    dialogService.tip([{"message":"失效成功"}]);
                }
            })
        };
        //启用
        $scope.active = function (openRoom) {
            CustomizationService.apiCustomizationSupplyChainopenRoomActive({id:openRoom.id,rowVersion:openRoom.rowVersion}).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    $scope.getOpenRoomList();
                    dialogService.tip([{"message":"启用成功"}]);
                }
            })
        }
        //监听
        $scope.$watch(function () {
            return $scope.import.data;
        }, function (newDate, oldDate) {
            if (oldDate == null && newDate != null) {
                if (newDate.isSuccessful){
                    location.reload(true);
                }
            }
        });
    };

    var app =angular.module("xn.page", [])
     .controller("DemandRoomIndexController",["$scope","dialogService","CustomizationService",demandRoomIndexController])
})();