AccountOrderCheckingDetailController.js 6.1 KB
"use strict";
var AccountOrderCheckingDetailController = angular.module('AccountOrderCheckingDetailController',[]);

//获取订单列表
AccountOrderCheckingDetailController.controller('AccountOrderCheckingDetailController', [
 	'$rootScope',
	'$scope',
	'AccountOrderCheckingDetailService',
	'SystemUserService',
	'SupplierService',
	function($rootScope, $scope, AccountOrderCheckingDetailService, SystemUserService,SupplierService) {
        var orderFrom = $rootScope.$stateParams.orderFrom;
        var orderStatus = $rootScope.$stateParams.orderStatus;
        var erpImport = $rootScope.$stateParams.erpImport;
        var orderCheckingId = $rootScope.$stateParams.orderCheckingId;
        $scope.suppliersFlag = 0;
        $scope.suppliers = [];
        $scope.orders = [];
        $scope.currentPage = 1;
        $scope.pageSize = 20;
        $scope.numPages = 1;
        $scope.totalRecord = 0;
        $scope.pages = [];
        $scope.choseAtrr = [];
        $scope.master = false;
        $scope.orderQuery = {
            orderCode: '',
            orderFrom: '',
            startCreateDt: '',
            endCreateDt: '',
            supplierId: '',
            phone: '',
            orderStatus: '',
            buyerUsername: '',
            buyerPhone: '',
            erpImport: '',
            pageNow: 1,
            pageSize: 20,
            orderCheckingId: '',
        };
        $scope.orderQuery.orderCheckingId = orderCheckingId;
        if (orderStatus > 0 || orderStatus != -1) {
            $scope.orderQuery.orderStatus = orderStatus;
        }
        if (erpImport) {
            $scope.orderQuery.erpImport = erpImport;
        }
        //获取商家列表
        SupplierService.listSupplier();
        $scope.$on('supplier.list', function () {
            $scope.suppliers = SupplierService.suppliers;
        });
        //获取当前用户信息
        SystemUserService.getCuurentUserinfo();
        $scope.$on('current.userinfo', function () {
            $scope.userinfo = SystemUserService.userinfo;
            if (SystemUserService.userinfo.platformFlag == false) {
                $scope.suppliersFlag = 1;
            }
        });
        //获取订单状态信息
        AccountOrderCheckingDetailService.statusList(orderFrom);
        $scope.$on('orders.orderStatusList', function () {
            $scope.orderStatus = AccountOrderCheckingDetailService.orderStatusList;
        });
        //获取订单列表
        $scope.orderQuery.orderFrom = orderFrom;
        if ($scope.orderQuery.orderStatus != null && $scope.orderQuery.orderStatus != '') {
            AccountOrderCheckingDetailService.orderPagerList($scope.orderQuery);
        }
        $scope.$on('orders.list', function () {
            $scope.orders = AccountOrderCheckingDetailService.orders;
            $scope.numPages = AccountOrderCheckingDetailService.orders.totalPage;
            $scope.totalRecord = AccountOrderCheckingDetailService.orders.totalRecord;
        });
        //导出表格
        $scope.exportProductExcel = function () {
            $scope.orderQuery.startCreateDt = $('#datepickfrom').val();
            $scope.orderQuery.endCreateDt = $('#datepickto').val();
            if ($scope.orderQuery.orderStatus != null && $scope.orderQuery.orderStatus != '') {
                if ($scope.orderQuery.startCreateDt == '') {
                    if (confirm("小主,你没有选择开始时间,导出数据很多,请耐心等待...")) {
                        window.open("../templateAccountOrder/exportAccountOrderCheckingExcel?orderCode=" + $scope.orderQuery.orderCode +
                            "&orderFrom=" + $scope.orderQuery.orderFrom + "&orderCheckingId=" + orderCheckingId +"&startCreateDt=" + $scope.orderQuery.startCreateDt +
                            "&endCreateDt=" + $scope.orderQuery.endCreateDt + "&phone=" + $scope.orderQuery.phone + "&orderStatus=" + $scope.orderQuery.orderStatus
                            + "&buyerUsername=" + $scope.orderQuery.buyerUsername + "&buyerPhone=" + $scope.orderQuery.buyerPhone + "&erpImport="
                            + $scope.orderQuery.erpImport + "&supplierId=" + $scope.orderQuery.supplierId);
                    }
                } else {
                    window.open("../templateAccountOrder/exportAccountOrderCheckingExcel?orderCode=" + $scope.orderQuery.orderCode +
                        "&orderFrom=" + $scope.orderQuery.orderFrom + "&startCreateDt=" + $scope.orderQuery.startCreateDt +
                        "&endCreateDt=" + $scope.orderQuery.endCreateDt + "&phone=" + $scope.orderQuery.phone + "&orderStatus=" + $scope.orderQuery.orderStatus
                        + "&buyerUsername=" + $scope.orderQuery.buyerUsername + "&buyerPhone=" + $scope.orderQuery.buyerPhone + "&erpImport="
                        + $scope.orderQuery.erpImport + "&supplierId=" + $scope.orderQuery.supplierId);
                }
            } else {
                alert("请选择订单状态!");
            }

        };
        //选当前页
        $scope.onSelectPage = function (page) {
            $scope.orderQuery.pageNow = page;
            $scope.currentPage = page;
            AccountOrderCheckingDetailService.orderPagerList($scope.orderQuery);
        };

        AccountOrderCheckingDetailService.orderPagerList($scope.orderQuery);
        $scope.searchOrder = function () {
            $scope.orderQuery.pageNow = 1;
            $scope.orderQuery.startCreateDt = $('#datepickfrom').val();
            $scope.orderQuery.endCreateDt = $('#datepickto').val();
            AccountOrderCheckingDetailService.orderPagerList($scope.orderQuery);
        };

    }
]);

//获取订单详情
AccountOrderCheckingDetailController.controller("AccountOrderCheckingContentController",[
	'$rootScope',
	'$scope',
	'AccountOrderCheckingDetailService',
	function($rootScope, $scope, AccountOrderCheckingDetailService) {
			var orderCode=$rootScope.$stateParams.orderCode;
			$scope.orderFrom=$rootScope.$stateParams.orderFrom;
			AccountOrderCheckingDetailService.orderDetail(orderCode);
			$scope.$on('orders.detail', function(){
				$scope.orderDetailBean = AccountOrderCheckingDetailService.orderDetailBean;
			});
		}
]);