openItem.js 3.43 KB
(function () {
    "use strict";

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

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

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

        $scope.getOpenItemList = function () {
            customizationService.apiCustomizationSupplyChainOpenItemFind($scope.vm).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    $scope.openItemList = data.result;
                    $scope.vm.totalCount = data.totalCount;
                }
            })
        };

        $scope.doSearch = function () {
            $scope.openItemList = [];
            customizationService.apiCustomizationSupplyChainopenItemSearch($scope.vm).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    $scope.openItemList = data.result;
                    $scope.vm.totalCount = data.totalCount;
                }
            })
        };

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

        $scope.getOpenItemList();
        //导出
        $scope.doExceport = function () {
            customizationService.apiCustomizationSupplyChainOpenItemExport($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 (openItem) {
            customizationService.apiCustomizationSupplyChainopenItemInactive({id:openItem.id,rowVersion:openItem.rowVersion}).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    $scope.getOpenItemList();
                    dialogService.tip([{"message":"失效成功"}]);
                }
            })
        };
        //启用
        $scope.active = function (openItem) {
            customizationService.apiCustomizationSupplyChainopenItemActive({id:openItem.id,rowVersion:openItem.rowVersion}).success(function (data) {
                if(data.errors === null || data.errors.length > 0){
                    dialogService.tip(data.errors);
                }else{
                    $scope.getOpenItemList();
                    dialogService.tip([{"message":"启用成功"}]);
                }
            })
        }
        //监听
        $scope.$watch(function () {
            return $scope.import.data;
        }, function (newDate, oldDate) {
            if (oldDate == null && newDate != null) {
                if (newDate.isSuccessful){
                    location.reload(true);
                }
            }
        });
    };

    angular.module("xn.page", [])
     .controller("OpenItemIndexController",["$scope","dialogService","CustomizationService",openItemIndexController])
})();