| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- define([ 'angular', 'common/utils', 'big'], function(angular, utils) {
- 'use strict';
- angular.module('common.b2bServices', [ 'common.utils', 'ngResource' ])
- .factory('SearchFilter', function() {
- return {
- /**
- * 改变单据日期范围
- */
- getDateCondition: function (zone, condition) {
- var fromDate = new Date();
- var toDate = new Date();
- //去除时分秒限制,dateFrom设置成0时0分0秒,dateTo设置成23时59分59秒
- fromDate.setHours(0, 0, 0, 0);
- toDate.setHours(23, 59, 59, 999);
- if (zone == -1) { // 自定义时间,什么都不做
- } else if (zone == 1) {
- fromDate.setMonth(fromDate.getMonth() - 1);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else if (zone == 3) {
- fromDate.setMonth(fromDate.getMonth() - 3);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else if (zone == 6) {
- fromDate.setMonth(fromDate.getMonth() - 6);
- condition.dateFrom = fromDate;
- condition.dateTo = toDate;
- } else {
- condition.dateFrom = null;
- condition.dateTo = null;
- }
- return condition;
- },
- /**
- * 改变单据交货日期范围
- */
- getDeliveryCondition: function (zone, condition) {
- var date = new Date();
- if (zone == -1) {
- condition.deliveryFrom = null;
- condition.deliveryTo = null;
- } else if (zone == 1) {
- date.setMonth(date.getMonth() + 1);
- condition.deliveryTo = date;
- condition.deliveryFrom = new Date();
- } else if (zone == 2) {
- date.setMonth(date.getMonth() + 2);
- condition.deliveryTo = date;
- condition.deliveryFrom = new Date();
- }
- return condition;
- },
- /**
- * 将日期转化为整数日期
- */
- getDateTime: function (date) {
- if (angular.isDate(date)) {
- return date.getTime();
- } else {
- return null;
- }
- },
- /**
- * 将date转成time
- *
- * @param date
- * @returns {string}
- */
- formatDateTime: function (date) {
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- m = m < 10 ? ('0' + m) : m;
- var d = date.getDate();
- d = d < 10 ? ('0' + d) : d;
- var h = date.getHours();
- var minute = date.getMinutes();
- var sec = date.getSeconds();
- minute = minute < 10 ? ('0' + minute) : minute;
- return y + '-' + m + '-' + d+' '+h+':'+minute+':'+sec;
- }
- };
- }).factory('B2bCommerce', ['$resource', function($resource) {
- return $resource('b2b/sale', {}, {
- accessUrl : {
- url: 'b2b/sale/accessUrl',
- method: 'GET'
- }
- });
- }]);
- });
|