|
|
@@ -0,0 +1,877 @@
|
|
|
+define(['app/app'], function(app) {
|
|
|
+ 'use strict';
|
|
|
+ app.register.controller('saleProductManageCtrl', ['$scope', '$modal', 'toaster', 'ngTableParams', 'BaseService', '$http', 'Goods', 'BackgroundRecord', 'Commodity', 'GoodsModifyInfo', function($scope, $modal, toaster, ngTableParams, BaseService, $http, Goods, BackgroundRecord, Commodity, GoodsModifyInfo) {
|
|
|
+ $scope.dateArea = 'oneMonth';
|
|
|
+ var _formatDate = function (date, fmt) {
|
|
|
+ if (!date) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (typeof date === 'string') {
|
|
|
+ date = new Date(Date.parse(date.replace(/-/g, '/')));
|
|
|
+ }
|
|
|
+ var o = {
|
|
|
+ 'M+': date.getMonth() + 1, // 月份
|
|
|
+ 'd+': date.getDate(), // 日
|
|
|
+ 'h+': date.getHours(), // 小时
|
|
|
+ 'm+': date.getMinutes(), // 分
|
|
|
+ 's+': date.getSeconds(), // 秒
|
|
|
+ 'q+': Math.floor((date.getMonth() + 3) / 3), // 季度
|
|
|
+ 'S': date.getMilliseconds() // 毫秒
|
|
|
+ }
|
|
|
+ if (/(y+)/.test(fmt)) {
|
|
|
+ fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
|
|
|
+ }
|
|
|
+ for (var k in o) {
|
|
|
+ if (new RegExp('(' + k + ')').test(fmt)) {
|
|
|
+ fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return fmt;
|
|
|
+ };
|
|
|
+ var _getClearDay = function (date) {
|
|
|
+ return new Date(_formatDate(date, 'yyyy-MM-dd')).getTime() - 8 * 60 * 60 * 1000
|
|
|
+ };
|
|
|
+
|
|
|
+ var currentTime = _getClearDay(new Date());
|
|
|
+ $scope.startDate = new Date(currentTime - 30 * 24 * 60 * 60 * 1000);
|
|
|
+ $scope.endDate = new Date(currentTime + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
|
|
|
+ $scope.startFormatDate = _formatDate($scope.startDate, 'yyyy-MM-dd');
|
|
|
+ $scope.endFormatDate = _formatDate($scope.endDate, 'yyyy-MM-dd');
|
|
|
+ var addStartDate = new Date($scope.startDate.getTime() + 24 * 60 * 60 * 1000)
|
|
|
+ var addEndDate = new Date($scope.endDate.getTime() + 24 * 60 * 60 * 1000)
|
|
|
+ $scope.addStartFormatDate = _formatDate(addStartDate, 'yyyy-MM-dd');
|
|
|
+ $scope.addEndFormatDate = _formatDate(addEndDate, 'yyyy-MM-dd');
|
|
|
+
|
|
|
+ $scope.setFilters = function (type, val) {
|
|
|
+ $scope[type] = val;
|
|
|
+ if (type == 'dateArea') {
|
|
|
+ // 时间筛选
|
|
|
+ var currentTime = _getClearDay(new Date());
|
|
|
+ var endDate = new Date(currentTime + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
|
|
|
+ if (val == 'oneMonth') {
|
|
|
+ $scope.startDate = new Date(currentTime - 30 * 24 * 60 * 60 * 1000 - 24 * 60 * 60 * 1000);
|
|
|
+ $scope.endDate = endDate;
|
|
|
+ } else if (val == 'threeMonth') {
|
|
|
+ $scope.startDate = new Date(currentTime - 3 * 30 * 24 * 60 * 60 * 1000 - 24 * 60 * 60 * 1000);
|
|
|
+ $scope.endDate = endDate;
|
|
|
+ } else if (val == 'sixMonth') {
|
|
|
+ $scope.startDate = new Date(currentTime - 6 * 30 * 24 * 60 * 60 * 1000 - 24 * 60 * 60 * 1000);
|
|
|
+ $scope.endDate = endDate;
|
|
|
+ } else if (val == 'allMonth') {
|
|
|
+ $scope.startDate = null;
|
|
|
+ $scope.endDate = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.startFormatDate = $scope.startDate ? _formatDate($scope.startDate, 'yyyy-MM-dd') : '';
|
|
|
+ $scope.endFormatDate = $scope.endDate ? _formatDate($scope.endDate, 'yyyy-MM-dd') : '';
|
|
|
+ if (val != 'autoMonth') {
|
|
|
+ $scope.manageTableParams.page(1);
|
|
|
+ $scope.manageTableParams.reload();
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.condition = [];
|
|
|
+ var start = {
|
|
|
+ open : false
|
|
|
+ };
|
|
|
+ var end = {
|
|
|
+ open : false
|
|
|
+ };
|
|
|
+ $scope.condition.push(start);
|
|
|
+ $scope.condition.push(end);
|
|
|
+ // 打开日期选择框
|
|
|
+ $scope.openDatePicker = function($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ openParam == 0 ? $scope.condition[1].open = false : $scope.condition[0].open = false;
|
|
|
+ item[openParam].open = !item[openParam].open;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.onDateCondition = function (bool, date) {
|
|
|
+ if (bool == 1) {
|
|
|
+ $scope.startDate = date;
|
|
|
+ } else {
|
|
|
+ $scope.endDate = date;
|
|
|
+ }
|
|
|
+ var startTime = $scope.startDate ? $scope.startDate.getTime() : null;
|
|
|
+ var endTime = $scope.endDate ? $scope.endDate.getTime() : null;
|
|
|
+ if (startTime && endTime && startTime > endTime) {
|
|
|
+ if (bool == 1) {
|
|
|
+ toaster.pop('info', '起始时间不能大于结束时间');
|
|
|
+ $scope.startDate = null;
|
|
|
+ } else {
|
|
|
+ toaster.pop('info', '结束时间不能小于起始时间');
|
|
|
+ $scope.endDate = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($scope.endDate && bool == 2) {
|
|
|
+ $scope.endDate = new Date($scope.endDate.getFullYear(), $scope.endDate.getMonth(), $scope.endDate.getDate())
|
|
|
+ $scope.endDate = new Date($scope.endDate.getTime() + 23 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000);
|
|
|
+ }
|
|
|
+ $scope.startFormatDate = $scope.startDate ? _formatDate($scope.startDate, 'yyyy-MM-dd') : '';
|
|
|
+ $scope.endFormatDate = $scope.endDate ? _formatDate($scope.endDate, 'yyyy-MM-dd') : '';
|
|
|
+ $scope.manageTableParams.page(1);
|
|
|
+ $scope.manageTableParams.reload();
|
|
|
+ };
|
|
|
+ $scope.goodsFilter = {};
|
|
|
+ $scope.kindPojo = {};
|
|
|
+ var initTitleInfo = function () {
|
|
|
+ BackgroundRecord.getUserTitle({}, function (data) {
|
|
|
+ $scope.tableTabs = data;
|
|
|
+ $scope.titleInShow = {};
|
|
|
+ angular.forEach($scope.tableTabs, function (item) {
|
|
|
+ $scope.titleInShow[item.titleName] = true;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ };
|
|
|
+ initTitleInfo();
|
|
|
+
|
|
|
+ $scope.saleStatus = {
|
|
|
+ 601 : '已上架',
|
|
|
+ 602 : '已上架',
|
|
|
+ 612 : '已下架',
|
|
|
+ 613 : '新品未上架'
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取分页Goods数据
|
|
|
+ $scope.manageTableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 10,
|
|
|
+ sorting: {
|
|
|
+ createTime : 'DESC'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ counts: [],
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ var param = BaseService.parseParams(params.url());
|
|
|
+ if($scope.startFormatDate) {
|
|
|
+ $scope.goodsFilter.startTime = $scope.startFormatDate
|
|
|
+ } else {
|
|
|
+ delete $scope.goodsFilter.startTime
|
|
|
+ }
|
|
|
+ if($scope.endFormatDate) {
|
|
|
+ $scope.goodsFilter.endTime = $scope.endFormatDate
|
|
|
+ } else {
|
|
|
+ delete $scope.goodsFilter.endTime
|
|
|
+ }
|
|
|
+ $scope.pageParams = param;
|
|
|
+ Goods.loadBrandProductsList(param, $scope.goodsFilter, function (data) {
|
|
|
+ $scope.totalCount = data.totalElements;
|
|
|
+ $scope.goodsList = data.content;
|
|
|
+ angular.forEach($scope.goodsList, function (list) {
|
|
|
+ list.isChoosed = false
|
|
|
+ });
|
|
|
+ params.total(data.totalElements);
|
|
|
+ $defer.resolve(data.content);
|
|
|
+ }, function () {
|
|
|
+ toaster.pop('error', '获取数据失败')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 全选
|
|
|
+ $scope.chooseAll = function () {
|
|
|
+ $scope.isChooseAll = !$scope.isChooseAll;
|
|
|
+ angular.forEach($scope.goodsList, function (list) {
|
|
|
+ list.isChoosed = $scope.isChooseAll;
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ // 检查是否全选
|
|
|
+ var checkChoosedAll = function () {
|
|
|
+ $scope.isChooseAll = true;
|
|
|
+ angular.forEach($scope.goodsList, function (list) {
|
|
|
+ if(!list.isChoosed) {
|
|
|
+ $scope.isChooseAll = false;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ // 单选
|
|
|
+ $scope.chooseOne = function (list) {
|
|
|
+ (typeof list.isChoosed === 'undefined' || !list.isChoosed) ? list.isChoosed = true : list.isChoosed = false;
|
|
|
+ checkChoosedAll();
|
|
|
+ };
|
|
|
+
|
|
|
+ //获取选中之后的信息
|
|
|
+ var getChooseBatch = function () {
|
|
|
+ $scope.choosedBatch = [];
|
|
|
+ $scope.ids = [];
|
|
|
+ angular.forEach($scope.goodsList, function (goods) {
|
|
|
+ if (goods.isChoosed) {
|
|
|
+ $scope.choosedBatch.push(goods.batchCode);
|
|
|
+ $scope.ids.push(goods);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.batchDown = function () {
|
|
|
+ getChooseBatch();
|
|
|
+ if (!$scope.choosedBatch || $scope.choosedBatch.length == 0) {
|
|
|
+ toaster.pop("info", "您尚未选中任何产品");
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+ $scope.soldOutProduct($scope.choosedBatch);
|
|
|
+ };
|
|
|
+
|
|
|
+ var initKindDataInfo = function () {
|
|
|
+ Commodity.getAllKindInfo({}, function (data) {
|
|
|
+ $scope.kindInfo = data[0].children;
|
|
|
+ })
|
|
|
+ };
|
|
|
+ initKindDataInfo();
|
|
|
+
|
|
|
+ // 是否打开树型选择
|
|
|
+ $scope.showSecondList = function () {
|
|
|
+ $scope.selectDown = true;
|
|
|
+ };
|
|
|
+ $scope.selectDown = false;
|
|
|
+ $scope.treeOptions = {
|
|
|
+ nodeChildren: "children",
|
|
|
+ dirSelectable: false,
|
|
|
+ injectClasses: {
|
|
|
+ ul: "a1",
|
|
|
+ li: "a2",
|
|
|
+ liSelected: "a7",
|
|
|
+ iExpanded: "a3",
|
|
|
+ iCollapsed: "a4",
|
|
|
+ iLeaf: "a5",
|
|
|
+ label: "a6",
|
|
|
+ labelSelected: "a8"
|
|
|
+ }
|
|
|
+ };
|
|
|
+ $scope.showSelected = function(node) {
|
|
|
+ $scope.leaf = node.nameCn;
|
|
|
+ $scope.selectDown = false;
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取根据当前类目的信息获取所有叶子节点的类目信息
|
|
|
+ *
|
|
|
+ * @param kind
|
|
|
+ */
|
|
|
+ function getAllLeafKindId(kind) {
|
|
|
+ if (!kind) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if (kind.isLeaf == 1) {
|
|
|
+ return kind.id;
|
|
|
+ }
|
|
|
+ if (kind.isLeaf == 0) {
|
|
|
+ // 获取第一级类目的所有叶子类目ID
|
|
|
+ if (kind.level == 1) {
|
|
|
+ var leafKindIds = [];
|
|
|
+ angular.forEach(kind.children, function (kind) {
|
|
|
+ // 获取第一级类目的直接子类目的所有叶子类目ID
|
|
|
+ var childrenIds = getAllLeafKindId(kind);
|
|
|
+ if (Array.isArray(childrenIds)) {
|
|
|
+ angular.forEach(childrenIds, function (child) {
|
|
|
+ leafKindIds.push(child);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ leafKindIds.push(childrenIds);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return leafKindIds;
|
|
|
+ } else if (kind.level == 2) {
|
|
|
+ // 获取第二级类目的所有叶子类目ID
|
|
|
+ var kindIds = [];
|
|
|
+ angular.forEach(kind.children, function (kind) {
|
|
|
+ kindIds.push(kind.id);
|
|
|
+ });
|
|
|
+ return kindIds;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 清空数据
|
|
|
+ $scope.clearClick = function () {
|
|
|
+ for( var tmp in $scope.goodsFilter) {
|
|
|
+ $scope.goodsFilter[tmp] = '';
|
|
|
+ }
|
|
|
+ for( var tmp in $scope.kindPojo) {
|
|
|
+ $scope.kindPojo[tmp] = '';
|
|
|
+ }
|
|
|
+ $scope.goodsFilter.kindUuid = '';
|
|
|
+ $scope.manageTableParams.page(1);
|
|
|
+ $scope.manageTableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 搜索事件
|
|
|
+ $scope.searchClick = function () {
|
|
|
+ if ($scope.kindPojo && $scope.kindPojo.first) {
|
|
|
+ if (!$scope.kindPojo.second) {
|
|
|
+ var kind = $scope.kindInfo[$scope.kindPojo.first];
|
|
|
+ var kindUuid = getAllLeafKindId(kind);
|
|
|
+ $scope.goodsFilter.kindUuid = kindUuid.join(',')
|
|
|
+ } else if ($scope.kindPojo.second && $scope.kindPojo.third) {
|
|
|
+ $scope.goodsFilter.kindUuid = getAllLeafKindId($scope.kindPojo.third);
|
|
|
+ } else {
|
|
|
+ var kind = $scope.kindInfo[$scope.kindPojo.first].children[$scope.kindPojo.second];
|
|
|
+ var kindUuid = getAllLeafKindId(kind);
|
|
|
+ $scope.goodsFilter.kindUuid = kindUuid.join(',')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $scope.manageTableParams.page(1);
|
|
|
+ $scope.manageTableParams.reload();
|
|
|
+ };
|
|
|
+
|
|
|
+ // 产品导出事件
|
|
|
+ $scope.exportClick = function () {
|
|
|
+ var url = '';
|
|
|
+ getChooseBatch();
|
|
|
+ if($scope.ids.length > 0) {
|
|
|
+ var idList = [];
|
|
|
+ angular.forEach($scope.ids, function(val) {
|
|
|
+ idList.push(val.id)
|
|
|
+ })
|
|
|
+ url = '/trade/products/background/downloadByIds?idStr=' + angular.toJson(idList);
|
|
|
+ } else {
|
|
|
+ // 拼装链接
|
|
|
+ url = "/trade/products/background/download?page=" + $scope.pageParams.page + "&count=" + $scope.pageParams.count + "&sorting=" + encodeURIComponent(angular.toJson($scope.pageParams.sorting));
|
|
|
+ if (angular.isDefined($scope.startDate) && null != $scope.startDate) {
|
|
|
+ url = url + "&startTime=" + $scope.startDate.getTime();
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.endDate) && null != $scope.endDate) {
|
|
|
+ url = url + "&endTime=" + $scope.endDate.getTime();
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.kindUuid)) {
|
|
|
+ url = url + "&kindUuid=" + $scope.goodsFilter.kindUuid;
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.code)) {
|
|
|
+ url = url + "&code=" + $scope.goodsFilter.code
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.brand)) {
|
|
|
+ url = url + "&brand=" + $scope.goodsFilter.brand
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.store)) {
|
|
|
+ url = url + "&store=" + $scope.goodsFilter.store
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.saleStatus)) {
|
|
|
+ url = url + "&saleStatus=" + $scope.goodsFilter.saleStatus
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.saleNum)) {
|
|
|
+ url = url + "&saleNum=" + $scope.goodsFilter.saleNum
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.currency)) {
|
|
|
+ url = url + "¤cy=" + $scope.goodsFilter.currency
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.saleSelf)) {
|
|
|
+ url = url + "&saleSelf=" + $scope.goodsFilter.saleSelf
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.bredakUp)) {
|
|
|
+ url = url + "&breakUp=" + $scope.goodsFilter.bredakUp
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.standard)) {
|
|
|
+ url = url + "&standard=" + $scope.goodsFilter.standard
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.audited)) {
|
|
|
+ url = url + "&audited=" + $scope.goodsFilter.audited
|
|
|
+ }
|
|
|
+ if (angular.isDefined($scope.goodsFilter.haveImg)) {
|
|
|
+ url = url + "&haveImg=" + $scope.goodsFilter.haveImg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ window.open(url);
|
|
|
+ /*var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/view/admin/modal/manage/exportProduct_modal.html',
|
|
|
+ controller: 'exportProductCtrl',
|
|
|
+ resolve: {
|
|
|
+ account: function () {
|
|
|
+ return angular.copy(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function (account) {
|
|
|
+
|
|
|
+ }, function () {
|
|
|
+
|
|
|
+ })*/
|
|
|
+ };
|
|
|
+
|
|
|
+ // 更多信息事件
|
|
|
+ $scope.moreInfo = function () {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/view/admin/modal/manage/moreInfo_modal.html',
|
|
|
+ controller: 'moreInfoCtrl',
|
|
|
+ resolve: {
|
|
|
+ titleInShow: function () {
|
|
|
+ return angular.copy($scope.titleInShow);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function (data) {
|
|
|
+ if (data) {
|
|
|
+ BackgroundRecord.updateUserTitle({}, data, function (data) {
|
|
|
+ if (data.success) {
|
|
|
+ if (data.data) {
|
|
|
+ initTitleInfo();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ toaster.pop("info", data.message);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ // 审核事件
|
|
|
+ $scope.auditProduct = function (goods) {
|
|
|
+ // 分页获取修改历史记录
|
|
|
+ // $scope.modifyTableParams = new ngTableParams({
|
|
|
+ // page: 1,
|
|
|
+ // count: 3
|
|
|
+ // }, {
|
|
|
+ // total: 0,
|
|
|
+ // getData: function ($defer, params) {
|
|
|
+ // var param = BaseService.parseParams(params.url());
|
|
|
+ // param.batchCode = goods.batchCode;
|
|
|
+ // GoodsModifyInfo.getPageModifyInfo(param, function (data) {
|
|
|
+ // var modalInstance = $modal.open({
|
|
|
+ // templateUrl: 'static/view/admin/modal/manage/manageAudit.html',
|
|
|
+ // controller: 'AuditCtrl',
|
|
|
+ // resolve: {
|
|
|
+ // goods: function () {
|
|
|
+ // return angular.copy(goods);
|
|
|
+ // },
|
|
|
+ // info: function () {
|
|
|
+ // return angular.copy(data.content);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // modalInstance.result.then(function (result) {
|
|
|
+ //
|
|
|
+ // }, function () {
|
|
|
+ //
|
|
|
+ // })
|
|
|
+ // params.total(data.totalElements);
|
|
|
+ // $defer.resolve(data.content);
|
|
|
+ // }, function () {
|
|
|
+ // toaster.pop('error', '获取数据失败')
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ GoodsModifyInfo.getModifyInfoByBatchCode({batchCode:goods.batchCode}, function (data) {
|
|
|
+ if (data) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/view/admin/modal/manage/manageAudit.html',
|
|
|
+ controller: 'AuditCtrl',
|
|
|
+ resolve: {
|
|
|
+ goods: function () {
|
|
|
+ return angular.copy(goods);
|
|
|
+ },
|
|
|
+ info: function () {
|
|
|
+ return angular.copy(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function () {
|
|
|
+ $scope.manageTableParams.reload();
|
|
|
+ }, function () {
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }, function (error) {
|
|
|
+ toaster.pop("error", error.data);
|
|
|
+ });
|
|
|
+
|
|
|
+ };
|
|
|
+ // 日志点击事件
|
|
|
+ $scope.journalProduct = function (goods) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/view/admin/modal/manage/journal_modal.html',
|
|
|
+ controller: 'journalCtrl',
|
|
|
+ resolve: {
|
|
|
+ goods: function () {
|
|
|
+ return angular.copy(goods);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function (account) {
|
|
|
+
|
|
|
+ }, function () {
|
|
|
+
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ // 下架事件
|
|
|
+ $scope.soldOutProduct = function (batchArray) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/view/admin/modal/manage/ManageSoldOut.html',
|
|
|
+ controller: 'soleOutCtrl',
|
|
|
+ resolve: {
|
|
|
+ batchArray: function () {
|
|
|
+ return angular.copy(batchArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ modalInstance.result.then(function () {
|
|
|
+ $scope.manageTableParams.reload();
|
|
|
+ }, function () {
|
|
|
+
|
|
|
+ })
|
|
|
+ };
|
|
|
+ // 显示对比图片信息
|
|
|
+ $scope.showImg = function (data) {
|
|
|
+ var modalInstance = $modal.open({
|
|
|
+ templateUrl: 'static/view/admin/modal/manage/showContrastImg_modal.html',
|
|
|
+ controller: 'showContrastImgCtrl',
|
|
|
+ resolve: {
|
|
|
+ img: function () {
|
|
|
+ return angular.copy(data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ modalInstance.result.then(function (account) {
|
|
|
+
|
|
|
+ }, function () {
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.register.controller('exportProductCtrl', ['$scope', '$modalInstance', 'account', function($scope, $modalInstance, account) {
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.register.controller('moreInfoCtrl', ['$scope', '$modalInstance', 'titleInShow', function ($scope, $modalInstance, titleInShow) {
|
|
|
+
|
|
|
+ $scope.allTitle = [{titleName : '商家ID'}, {titleName : '商家名称'}, {titleName : '产品信息'}, {titleName : 'SKU编码'},
|
|
|
+ {titleName : '产品编号'}, {titleName : '封装'}, {titleName : '梯度'}, {titleName : '单价'}, {titleName : '交期(天)'},
|
|
|
+ {titleName : '包装'}, {titleName : '包装数量'}, {titleName : '起订量'}, {titleName : '拆包售卖'}, {titleName : '在售数量'},
|
|
|
+ {titleName : '锁库数'}, {titleName : '冻结数量'}, {titleName : '库存总数'}, {titleName : '在售状态'}, {titleName : '销售方式'},
|
|
|
+ {titleName : '创建人'}, {titleName : '创建时间'}, {titleName : '产品类型'}, {titleName : '图片类型'}, {titleName : '产品图片'}];
|
|
|
+
|
|
|
+ var initTitleInfo = function () {
|
|
|
+ angular.forEach($scope.allTitle, function (item) {
|
|
|
+ if (titleInShow[item.titleName]) {
|
|
|
+ item.choosed = true;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ };
|
|
|
+ initTitleInfo();
|
|
|
+
|
|
|
+ var getChooseInfo = function () {
|
|
|
+ $scope.titleSet = [];
|
|
|
+ angular.forEach($scope.allTitle, function (item) {
|
|
|
+ if (item.choosed) {
|
|
|
+ $scope.titleSet.push(item);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.ensureAddAccount = function () {
|
|
|
+ getChooseInfo();
|
|
|
+ $modalInstance.close($scope.titleSet);
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.register.controller('AuditCtrl', ['$scope', 'goods', 'info', 'toaster', '$modalInstance', 'GoodsModifyInfo', function($scope, goods, info, toaster, $modalInstance, GoodsModifyInfo) {
|
|
|
+ $scope.auditGoods = goods;
|
|
|
+ $scope.modifyList = info;
|
|
|
+ $scope.hasAuditTwo = false;
|
|
|
+ $scope.errorMsg = '';
|
|
|
+ $scope.otherMessage = '';
|
|
|
+ $scope.errorArray = ['价格异常', '图片违规', '基本信息有误', '断缺货'];
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.toggleAudit = function (type) {
|
|
|
+ $scope.hasAuditTwo = type
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.changeType = function (type) {
|
|
|
+ $scope.errorType = type;
|
|
|
+ };
|
|
|
+
|
|
|
+ var countLength = function (string) {
|
|
|
+ return string.replace(/[^\x00-\xff]/g, '**').length;
|
|
|
+ };
|
|
|
+
|
|
|
+ var cutOutString = function (str, length) {
|
|
|
+ for (var i = 1; i <= str.length; i++) {
|
|
|
+ if (countLength(str.substr(0, i)) > length){
|
|
|
+ str = str.substr(0, i-1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.inputMessage = function () {
|
|
|
+ if ($scope.otherMessage) {
|
|
|
+ $scope.otherMessage = cutOutString($scope.otherMessage, 30);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.ensureAudit = function (pass) {
|
|
|
+ if (!pass) {
|
|
|
+ if (!$scope.errorType) {
|
|
|
+ toaster.pop("info", "您尚未选择下架原因");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($scope.errorType == 5) {
|
|
|
+ if (!$scope.otherMessage || countLength($scope.otherMessage) < 2) {
|
|
|
+ toaster.pop("info", "原因至少要填写2个字");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($scope.errorType == 5) {
|
|
|
+ $scope.errorMsg = $scope.otherMessage;
|
|
|
+ } else {
|
|
|
+ $scope.errorMsg = $scope.errorArray[$scope.errorType - 1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ GoodsModifyInfo.auditedGoods({batchCode:goods.batchCode,pass:pass,message:$scope.errorMsg}, {}, function () {
|
|
|
+ toaster.pop("info", "审核完毕");
|
|
|
+ $modalInstance.close();
|
|
|
+ })
|
|
|
+ };
|
|
|
+
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.register.controller('journalCtrl', ['$scope', 'goods', 'toaster', 'ngTableParams', 'BaseService', 'GoodsHistory', 'GoodsModifyInfo', '$modalInstance', function($scope, goods, toaster, ngTableParams, BaseService, GoodsHistory, GoodsModifyInfo, $modalInstance) {
|
|
|
+ $scope.tabs = 'basic';
|
|
|
+
|
|
|
+ // 日期选择框部分
|
|
|
+ $scope.condition = [{open: false},{open: false} ];
|
|
|
+ $scope.openDatePicker = function ($event, item, openParam) {
|
|
|
+ $event.preventDefault();
|
|
|
+ $event.stopPropagation();
|
|
|
+ openParam === 0 ? $scope.condition[1].open = false : $scope.condition[0].open = false;
|
|
|
+ item[openParam].open = !item[openParam].open;
|
|
|
+ };
|
|
|
+ $scope.onDateCondition = function (bool) {
|
|
|
+ if (bool === 1) {
|
|
|
+ if ($scope.startDate && !$scope.endDate) {
|
|
|
+ var nowTime = new Date();
|
|
|
+ $scope.endDate = new Date(nowTime.getFullYear(), nowTime.getMonth(), nowTime.getDate());
|
|
|
+ if ($scope.endDate.getTime() == $scope.startDate.getTime()) {
|
|
|
+ $scope.endDate = new Date($scope.endDate.getTime() + 86400000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($scope.startDate && $scope.endDate) {
|
|
|
+ if($scope.startDate.getTime() > $scope.endDate) {
|
|
|
+ $scope.endDate = new Date($scope.startDate.getTime() + 86400000)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (bool === 2) {
|
|
|
+ if ($scope.startDate && $scope.endDate) {
|
|
|
+ $scope.startDate = new Date($scope.endDate.getTime() - 86400000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.convertTab = function (tab) {
|
|
|
+ $scope.tabs = tab;
|
|
|
+ $scope.startDate = null;
|
|
|
+ $scope.endDate = null;
|
|
|
+ $scope.keyword = null;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.search = function (tab) {
|
|
|
+ switch (tab) {
|
|
|
+ case 'basic':
|
|
|
+ $scope.ModifyDetailTableParams.page(1);
|
|
|
+ $scope.ModifyDetailTableParams.reload();
|
|
|
+ break;
|
|
|
+ case 'sell':
|
|
|
+ $scope.ModifyDetailTableParams.page(1);
|
|
|
+ $scope.ModifyDetailTableParams.reload();
|
|
|
+ break;
|
|
|
+ case 'smt':
|
|
|
+ $scope.historyTableParams.page(1);
|
|
|
+ $scope.historyTableParams.reload();
|
|
|
+ break;
|
|
|
+ case 'audit':
|
|
|
+ $scope.auditedTableParams.page(1);
|
|
|
+ $scope.auditedTableParams.reload();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.historyStatus = {
|
|
|
+ '上架' : '上架',
|
|
|
+ '发布商品' : '上架',
|
|
|
+ '下架商品' : '下架',
|
|
|
+ '批量下架公司产品' : '下架'
|
|
|
+ };
|
|
|
+
|
|
|
+ var initQueryParams = function (param) {
|
|
|
+ if ($scope.startDate) {
|
|
|
+ param.startDate = $scope.startDate.getTime();
|
|
|
+ }
|
|
|
+ if ($scope.endDate) {
|
|
|
+ param.endDate = $scope.endDate.getTime();
|
|
|
+ }
|
|
|
+ if ($scope.keyword) {
|
|
|
+ param.keyword = $scope.keyword;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取分页GoodsHistory数据
|
|
|
+ $scope.historyTableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 3,
|
|
|
+ sorting: {
|
|
|
+ operateDate : 'DESC'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ var param = BaseService.parseParams(params.url());
|
|
|
+ param.batchCode = goods.batchCode;
|
|
|
+ initQueryParams(param);
|
|
|
+ GoodsHistory.findDataOfUpAndDown(param, function (data) {
|
|
|
+ $scope.historyList = data.content;
|
|
|
+ params.total(data.totalElements);
|
|
|
+ $defer.resolve(data.content);
|
|
|
+ }, function () {
|
|
|
+ toaster.pop('error', '获取数据失败')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.auditedTableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 3,
|
|
|
+ sorting: {
|
|
|
+ updateTime : 'DESC'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ var param = BaseService.parseParams(params.url());
|
|
|
+ param.batchCode = goods.batchCode;
|
|
|
+ initQueryParams(param);
|
|
|
+ GoodsModifyInfo.getPageModifyInfo(param, function (data) {
|
|
|
+ $scope.auditedList = data.content;
|
|
|
+ params.total(data.totalElements);
|
|
|
+ $defer.resolve(data.content);
|
|
|
+ }, function () {
|
|
|
+ toaster.pop('error', '获取数据失败')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.ModifyDetailTableParams = new ngTableParams({
|
|
|
+ page: 1,
|
|
|
+ count: 3,
|
|
|
+ sorting: {
|
|
|
+ updateTime : 'DESC'
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ total: 0,
|
|
|
+ getData: function ($defer, params) {
|
|
|
+ var param = BaseService.parseParams(params.url());
|
|
|
+ param.batchCode = goods.batchCode;
|
|
|
+ initQueryParams(param);
|
|
|
+
|
|
|
+ GoodsModifyInfo.getPageModifyDetail(param, function (data) {
|
|
|
+ $scope.detailList = data.content;
|
|
|
+ params.total(data.totalElements);
|
|
|
+ $defer.resolve(data.content);
|
|
|
+ }, function () {
|
|
|
+ toaster.pop('error', '获取数据失败')
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ app.register.controller('soleOutCtrl', ['$scope', 'batchArray', 'Goods', 'toaster', '$modalInstance', function($scope, batchArray, Goods, toaster, $modalInstance) {
|
|
|
+ $scope.errorMsg = '';
|
|
|
+ $scope.otherMessage = '';
|
|
|
+ $scope.errorArray = ['价格异常', '图片违规', '基本信息有误', '短缺货'];
|
|
|
+
|
|
|
+ var countLength = function (string) {
|
|
|
+ return string.replace(/[^\x00-\xff]/g, '**').length;
|
|
|
+ };
|
|
|
+
|
|
|
+ var cutOutString = function (str, length) {
|
|
|
+ for (var i = 1; i <= str.length; i++) {
|
|
|
+ if (countLength(str.substr(0, i)) > length){
|
|
|
+ str = str.substr(0, i-1);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return str;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.inputMessage = function () {
|
|
|
+ if ($scope.otherMessage) {
|
|
|
+ $scope.otherMessage = cutOutString($scope.otherMessage, 30);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.changeType = function (type) {
|
|
|
+ $scope.errorType = type;
|
|
|
+ };
|
|
|
+
|
|
|
+ $scope.ensureDown = function () {
|
|
|
+ if (!$scope.errorType) {
|
|
|
+ toaster.pop("info", "您尚未选择下架原因");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($scope.errorType == 5) {
|
|
|
+ if (!$scope.otherMessage || countLength($scope.otherMessage) < 2) {
|
|
|
+ toaster.pop("info", "原因至少要填写2个字");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($scope.errorType == 5) {
|
|
|
+ $scope.errorMsg = $scope.otherMessage;
|
|
|
+ } else {
|
|
|
+ $scope.errorMsg = $scope.errorArray[$scope.errorType - 1];
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$scope.errorMsg || $scope.errorMsg.length == 0) {
|
|
|
+ toaster.pop("info", "您尚未选择下架原因");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var batchs = batchArray.join(",");
|
|
|
+ Goods.offShelfGoodsByProvider({batchCodes:batchs, downMsg:$scope.errorMsg}, {}, function(map){
|
|
|
+ if (map.success) {
|
|
|
+ toaster.pop('success', '下架成功');
|
|
|
+ $modalInstance.close();
|
|
|
+ } else {
|
|
|
+ toaster.pop('error', map.message);
|
|
|
+ }
|
|
|
+ }, function() {
|
|
|
+ toaster.pop('error', '下架失败');
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ }]);
|
|
|
+ app.register.controller('showContrastImgCtrl', ['$scope', 'img', '$modalInstance', function ($scope, img, $modalInstance) {
|
|
|
+ $scope.showImgs = img;
|
|
|
+ $scope.cancel = function () {
|
|
|
+ $modalInstance.dismiss();
|
|
|
+ }
|
|
|
+ }]);
|
|
|
+
|
|
|
+ //器件选择功能方法
|
|
|
+ app.register.factory('TreeData', function() {
|
|
|
+ return function (tree) {
|
|
|
+ var me = this;
|
|
|
+ me.$data = tree;
|
|
|
+ }
|
|
|
+ })
|
|
|
+})
|