Kaynağa Gözat

客户公共询价增加商机、企业公共询价等功能,并且相应的功能已做调整

hejq 7 yıl önce
ebeveyn
işleme
016b7add4d

+ 244 - 596
src/main/webapp/resources/js/index/app.js

@@ -5379,341 +5379,6 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     // 公共询价列表
     // 公共询价列表
     app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', 'publicInquiry', 'publicInquiryList', '$modal', '$http', 'AccountEnterprise', 'customer', 'AuthenticationService', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry, publicInquiry, publicInquiryList, $modal, $http, AccountEnterprise, customer, AuthenticationService) {
     app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', 'publicInquiry', 'publicInquiryList', '$modal', '$http', 'AccountEnterprise', 'customer', 'AuthenticationService', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry, publicInquiry, publicInquiryList, $modal, $http, AccountEnterprise, customer, AuthenticationService) {
         BaseService.scrollBackToTop();
         BaseService.scrollBackToTop();
-        /**
-         * 改变单据日期范围
-         */
-        var getTenderDateCondition = function (zone, condition) {
-            var date = new Date();
-            if (zone == -1) {
-                condition.dateFrom = null;
-                condition.dateTo = null;
-            } else if (zone == 7) { // 一星期内
-                date.setHours(0, 0, 0 ,0);
-                date.setDate(date.getDate() - 7);
-                condition.dateFrom = date;
-                var ndate = new Date();
-                ndate.setHours(23, 59, 59 ,999);
-                ndate.setDate(ndate.getDate() - 1);
-                condition.dateTo = ndate;
-            } else if (zone == 1) { // 一个月内
-                date.setMonth(date.getMonth() - 1);
-                condition.dateFrom = date;
-                condition.dateTo = new Date();
-            } else if (zone == 3) { // 三个月内
-                date.setMonth(date.getMonth() - 3);
-                condition.dateFrom = date;
-                condition.dateTo = new Date();
-            } else if (zone == 6) { // 半年内
-                date.setMonth(date.getMonth() - 6);
-                condition.dateFrom = date;
-                condition.dateTo = new Date();
-            } else {  // 一年内
-                date.setYear(date.getYear() - 1);
-                condition.dateFrom = date;
-                condition.dateTo = new Date();
-            }
-        };
-
-        $scope.active = 'enterprise';
-        $scope.dateZoneText = '不限';
-        $scope.deliveryZoneText = '不限';
-        $scope.condition = {dateZone: -1};
-        $scope.changeDateZone = function (zone) {
-            $scope.condition.dateZone = zone;
-            $scope.condition.$dateZoneOpen = false;
-            getTenderDateCondition(zone, $scope.condition);
-            $scope.tableParams.page(1);
-            $scope.tableParams.reload();
-        };
-
-        $scope.openDatePicker = function ($event, item, openParam) {
-            $event.preventDefault();
-            $event.stopPropagation();
-            item[openParam] = !item[openParam];
-        };
-
-        $scope.parseDate = function (dateStr) {
-            if (dateStr)
-                return Date.parse(dateStr, 'yyyy-MM-dd');
-            return new Date();
-        };
-
-        $scope.isOverDue = function (date) {
-            if (date) {
-                var ndate = new Date();
-                ndate.setHours(23, 59, 59 ,999);
-                ndate.setDate(ndate.getDate());
-                var timestamp = Date.parse(ndate);
-                if (date > timestamp) {
-                    return true;
-                } else {
-                    return false;
-                }
-            } else {
-                return true;
-            }
-        }
-        // 选择查找日期
-        $scope.onDateCondition = function () {
-            $scope.tableParams.page(1);
-            $scope.tableParams.reload();
-        };
-
-        $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
-        var getState = function (active) {
-            var fn = 'getOpenAll';
-            switch (active) {
-                case 'all':
-                    fn = 'getOpenAll';
-                    break;
-                case 'todo':
-                    fn = 'getOpenTodo';
-                    break;
-                case 'end':
-                    fn = 'getOpenEnd';
-                    break;
-            }
-            return fn;
-        };
-
-        customer.distribute({}, function(data) {
-           $scope.customer = data;
-        });
-
-        $scope.setActive = function (state) {
-            if ($scope.active != state) {
-                $scope.active = state;
-                if ($scope.active == 'enterprise') {
-                    $scope.distribute = null;
-                    $scope.remind = false;
-                } else if ($scope.active == 'customer') {
-                    $scope.distribute = $scope.customer;
-                    if ($scope.distribute.length == 0) {
-                        $scope.distribute = [0];
-                    }
-                    $scope.remind = false;
-                } else if ($scope.active == 'remind') {
-                    $scope.remind = true;
-                } else if ($scope.active == 'all') {
-                    $scope.distribute = null;
-                    $scope.remind = false;
-                }
-                if ($scope.tableParams.page() == 1) {
-                    $scope.tableParams.reload();
-                } else {
-                    $scope.tableParams.page(1);
-                }
-            }
-        };
-
-        var getService = function () {
-            return publicInquiryList.getInquirylist;
-        }
-
-        $scope.tableParams = new ngTableParams({
-            page: 1,
-            count: 20,
-            sorting: {
-            }
-        }, {
-            total: 0,
-            counts: [10, 25, 50, 100],
-            getData: function ($defer, params) {
-                $scope.loading = true;
-                var pageParams = params.url();
-                pageParams.searchFilter = { // 筛选条件
-                    keyword: $scope.keyword,
-                    fromDate: getDateTime($scope.condition.dateFrom),
-                    endDate: getDateTime($scope.condition.dateTo)
-                };
-
-                AccountEnterprise.get({}, function(data) {
-                   $scope.currentEn = data;
-                    publicInquiry.getUrl({}, function(data) {
-                        $scope.url = data.url;
-                        if ($scope.active == 'enterprise') {// 企业商机
-                            AuthenticationService.getAuthentication().success(function (data) {
-                                $scope.loading = false;
-                                $scope.thisUser = data;
-                                $http({
-                                    method: 'get',
-                                    dataType: 'json',
-                                    url: $scope.url + '/inquiry/sale/enremind',
-                                    params: {
-                                        pageNumber: pageParams.page,
-                                        pageSize: pageParams.count,
-                                        useruu: $scope.thisUser.userUU,
-                                        enuu: $scope.currentEn.uu,
-                                        keyword: $scope.keyword,
-                                        fromDate: getDateTime($scope.condition.dateFrom),
-                                        endDate: getDateTime($scope.condition.dateTo)
-                                    }
-                                }).success(function (response) {
-                                    $scope.loading = false;
-                                    if (response) {
-                                        params.total(response.totalElements);
-                                        $defer.resolve(response.content);
-                                        $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
-                                    }
-                                }).error(function (err) {
-                                    $scope.loading = false;
-                                    toaster.pop('error', '数据加载失败', err);
-                                });
-                            });
-                        } else if ($scope.active == 'remind') {// 推荐报价信息
-                            AuthenticationService.getAuthentication().success(function (data) {
-                                $scope.loading = false;
-                                $scope.thisUser = data;
-                                $http({
-                                    method: 'get',
-                                    dataType: 'json',
-                                    url: $scope.url + '/inquiry/sale/remind',
-                                    params: {pageNumber: pageParams.page, pageSize: pageParams.count, useruu: $scope.thisUser.userUU, enuu: $scope.currentEn.uu,
-                                        keyword: $scope.keyword, fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)}
-                                }).success(function (response) {
-                                    $scope.loading = false;
-                                    if (response) {
-                                        params.total(response.totalElements);
-                                        $defer.resolve(response.content);
-                                        $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
-                                    }
-                                }).error(function (err) {
-                                    $scope.loading = false;
-                                    toaster.pop('error', '数据加载失败', err);
-                                });
-                            });
-                        } else if ($scope.active == 'all') {// 全部
-                            $http({
-                                method: 'get',
-                                dataType: 'json',
-                                url: $scope.url + '/inquiry/public',
-                                params: {pageNumber: pageParams.page, pageSize: pageParams.count, enUU: $scope.currentEn.uu, keyword: $scope.keyword,
-                                    fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo), distribute: $scope.distribute, remind: $scope.remind}
-                            }).success(function (response) {
-                                $scope.loading = false;
-                                if (response) {
-                                    params.total(response.totalElements);
-                                    $defer.resolve(response.content);
-                                    $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
-                                }
-                            }).error(function (err) {
-                                $scope.loading = false;
-                                toaster.pop('error', '数据加载失败', err);
-                            });
-                        }
-
-                        // 顶部滚动消息
-                        $http({
-                            method: 'get',
-                            url: $scope.url + '/inquiry/public/messageList',
-                            params: {enuu: $scope.currentEn.uu, size: 10},
-                            dataType: 'json'
-                        }).success(function(data) {
-                            $scope.message = data;
-                        }).error(function(error) {
-
-                        });
-                    });
-                });
-            }
-        });
-
-        $scope.toDetail = function (item) {
-            if (item.quoted == 0) {
-                window.location.hash = '#/baseInfo/inquiryList/' + item.id;
-            } else {
-                window.open("#/sale/pubinquiry/" + item.quteId);
-            }
-        };
-
-        // 转客户询价
-        $scope.qute = function (remind) {
-            $http({
-                method: 'get',
-                dataType: 'json',
-                url: $scope.url + '/inquiry/sale/quote',
-                params: {id: remind.itemId, en_uu: $scope.currentEn.uu}
-            }).success(function (response) {
-                $scope.loading = false;
-                if (response.inquiry != null) {
-                    toaster.pop('error', '该单据已报价');
-                } else {
-                    $http({
-                        method: 'get',
-                        dataType: 'json',
-                        url: $scope.url + '/inquiry/public/findItemByItemId',
-                        params: {itemId: remind.itemId, enuu: $scope.currentEn.uu}
-                    }).success(function (response) {
-                        var inquiryItem = response;
-                        var modalInstance = $modal.open({
-                            templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
-                            controller: 'QuoteCtrl',
-                            size: 'lg',
-                            resolve: {
-                                inquiryItem: function () {
-                                    return inquiryItem
-                                }
-                            }
-                        });
-
-                        modalInstance.result.then(function (data) {
-                            $scope.tableParams.reload();
-                        }, function () {
-
-                        });
-                    }).error(function (error) {
-                        toaster.pop('error', '数据加载失败', error);
-                    });
-                }
-            }).error(function (err) {
-                toaster.pop('error', '数据加载失败', err);
-            });
-        }
-
-        // 跳转详情
-        $scope.remindDetail = function(remind) {
-            if (remind.newId == null) {
-                window.location.hash = '#/baseInfo/inquiryList/' + remind.itemId;
-            } else {
-                window.open("#/sale/pubinquiry/" + remind.newId);
-            }
-        }
-
-        // 搜索框回车
-        $scope.onSearch = function () {
-            $scope.tableParams.page(1);
-            $scope.tableParams.reload();
-        };
-
-        // 转客户询价
-        $scope.transtoInquiry = function (inquiryItem) {
-            if ($scope.currentEn.uu == inquiryItem.inquiry.enUU) {
-                toaster.pop('warning', '不能对自己企业报价');
-            } else {
-                var modalInstance = $modal.open({
-                    templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
-                    controller: 'QuoteCtrl',
-                    size: 'lg',
-                    resolve: {
-                        inquiryItem: function () {
-                            return inquiryItem
-                        }
-                    }
-                });
-
-                modalInstance.result.then(function (data) {
-                    $scope.tableParams.reload();
-                }, function () {
-
-                });
-            }
-        }
-
-        // 跳转到我的报价列表
-        $scope.linkToInquiry = function () {
-            window.open("#/sale/pubinquiry");
-        }
-
     }]);
     }]);
 
 
     /**
     /**
@@ -22913,7 +22578,8 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     /**
     /**
      * 针对卖家,已转询价的公共询价单列表
      * 针对卖家,已转询价的公共询价单列表
      */
      */
-    app.controller('SalePubInquiryCtrl', ['$scope', '$filter', 'PubInquirySearchInfo', 'ngTableParams', 'toaster', 'BaseService', 'PubInquiryNoSearchInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', 'publicInquiry', '$modal', 'AccountEnterprise', '$http', function ($scope, $filter, PubInquirySearchInfo, ngTableParams, toaster, BaseService, PubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry, $modal, AccountEnterprise, $http) {
+    app.controller('SalePubInquiryCtrl', ['$scope', '$filter', 'PubInquirySearchInfo', 'ngTableParams', 'toaster', 'BaseService', 'PubInquiryNoSearchInfo', '$upload', '$rootScope', 'token', '$timeout', 'CurrentRole', 'publicInquiry', '$modal', 'AccountEnterprise', '$http', 'customer', 'AuthenticationService',
+        function ($scope, $filter, PubInquirySearchInfo, ngTableParams, toaster, BaseService, PubInquiryNoSearchInfo, $upload, $rootScope, token, $timeout, CurrentRole, publicInquiry, $modal, AccountEnterprise, $http, customer, AuthenticationService) {
         BaseService.scrollBackToTop();
         BaseService.scrollBackToTop();
 
 
         // 获取当前用户是否为普通用户
         // 获取当前用户是否为普通用户
@@ -22921,6 +22587,18 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             $scope.isUser = data.isUser;
             $scope.isUser = data.isUser;
         });
         });
 
 
+        /**
+         *  active 状态说明:
+         *  all: 客户公共询价单全部
+         *  done: 已报价
+         *  agreed: 已采纳
+         *  refused: 未采纳
+         *  invalid: 已失效
+         *  todo**: 待报价
+         *  todoAll: 所有公共询价
+         *  todoRemind: 个人商机
+         *  todoComRemind: 企业商机
+         */
         if ($rootScope.active) {
         if ($rootScope.active) {
             $scope.active = $rootScope.active;
             $scope.active = $rootScope.active;
             $rootScope.active = null;
             $rootScope.active = null;
@@ -22962,11 +22640,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                     $scope.tableParams.page(1);
                     $scope.tableParams.page(1);
             }
             }
         };
         };
-
-        $scope.searchMethod = false;
-        var getService = function () {
-            return $scope.searchMethod ? PubInquirySearchInfo : PubInquiryNoSearchInfo;
-        };
+        $scope.url = null;
         $scope.tableParams = new ngTableParams({
         $scope.tableParams = new ngTableParams({
             page: 1,
             page: 1,
             count: 20,
             count: 20,
@@ -22975,266 +22649,122 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                 'inquiry.enterprise.enName': 'asc',
                 'inquiry.enterprise.enName': 'asc',
                 'inquiry.code': 'asc'
                 'inquiry.code': 'asc'
             }
             }
-        }, {
-            total: 0,
-            counts: [5, 10, 25, 50],
-            getData: function ($defer, params) {
-                $scope.loading = true;
-                var pageParams = params.url();
-                var realActive = {};
-                pageParams.searchFilter = { // 筛选条件
-                    keyword: $scope.keyword,
-                    fromDate: getDateTime($scope.condition.dateFrom),
-                    endDate: getDateTime($scope.condition.dateTo)
-                };
-                if ($scope.active == 'overdue') {
-                    $scope.active = 'end';
-                }
-                AccountEnterprise.get({}, function(data) {
-                    $scope.currentEn = data;
-                    publicInquiry.getUrl({}, function(data) {
-                        var url = data.url;
-                        var filter = {vendUU: $scope.currentEn.uu, keyword: $scope.keyword,
-                            fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)};
-                        $http({
-                            method: 'get',
-                            dataType: 'json',
-                            url: url + '/inquiry/public/quotation/list',
-                            params: {pageNumber: pageParams.page, pageSize: pageParams.count, filter: filter, _state: $scope.active}
-                        }).success(function (response) {
-                            $scope.loading = false;
-                            if (response) {
-                                params.total(response.totalElements);
-                                $defer.resolve(response.content);
-                            }
-                        }).error(function (err) {
-                            $scope.loading = false;
-                            toaster.pop('error', '数据加载失败', err);
-                        });
-                    });
-                });
-            }
-        });
-
-        $scope.isUnread = function (id) {
-            for (var i in $scope.unreadCode) {
-                if (id == $scope.unreadCode[i]) {
-                    return true;
-                }
-            }
-        };
-
-        $scope.getMinDate = function (item) {
-            return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
-        };
-        $scope.replyPrices = [];
-        $scope.replylapQtys = [];
-        $scope.replyPrices.push(true);
-        $scope.replylapQtys.push(true);
-        $scope.addStep = function (inquiryItem) {
-            $scope.replyPrices.push(true);
-            if (inquiryItem.replies.length >= 10) {
-                toaster.pop('warning', '提示', '最多支持10个分段!');
-            } else {
-                inquiryItem.replies.push({});
-                if (inquiryItem.replies.length != 1) {
-                    $scope.replyPrices.push(true);
-                    $scope.replylapQtys.push(true);
-                }
-            }
-        };
-        $scope.removeStep = function (inquiryItem, stepIndex) {
-            inquiryItem.replies.splice(stepIndex, 1);
-            $scope.replyPrices.splice(stepIndex, 1);
-            $scope.replylapQtys.splice(stepIndex, 1);
-        };
-
-        $scope.openDatePicker = function ($event, item, openParam) {
-            $event.preventDefault();
-            $event.stopPropagation();
-            item[openParam] = !item[openParam];
-        };
-
-        $scope.openFilterDatePicker = function ($event, item, openParam) {
-            $event.preventDefault();
-            $event.stopPropagation();
-            item[openParam] = !item[openParam];
-            if ($scope.condition.dateFrom && $scope.condition.dateTo && !item[openParam]) {
-                $scope.tableParams.reload();
-            }
-        };
-
-        $scope.getHistory = function (item) {
-            if (!item.history) {
-                publicInquiry.getHistory({itemId: item.id}, function (data) {
-                    item.history = data;
-                });
-            }
-        };
-
-        // 报价
-        $scope.quote = function(inquiryItem) {
-            $modal.open({
-                animation: true,
-                templateUrl: 'static/tpl/index/sale/modal/quote_inquiry.html',
-                controller: 'QuoteInquiryCtrl',
-                resolve: {
-                    inquiryItem: function () {
-                        return inquiryItem
-                    }
-                }
-            }).result.then(function (data) {
-
-            }, function () {})
-        };
-
-        $scope.deleteAttach = function (attaches, index) {
-            attaches.splice(index, 1);
-        };
-
-        $scope.onReplyClick = function (item, withSteps) {
-            if (item.vendFromDate instanceof Date) {
-                item.vendFromDate = item.vendFromDate.getTime();
-            }
-            if (item.vendToDate instanceof Date) {
-                item.vendToDate = item.vendToDate.getTime();
-            }
-            if (item.vendFromDate > item.vendToDate) {
-                toaster.pop('warning', '警告', '有效开始日期不能超过有效截止日期');
-                return;
-            }
-            var replies = [];
-            // 判断分段数是否合法
-            var valid = true;
-            var validLapQty = 0;
-            angular.forEach(item.replies, function (r, i) {
-                if ((i > 0 ? r.lapQty : 1) || r.price) {
-                    replies.push(r);
-                }
-                // 直接比较是字符串比较,需要先转换再比较  2017年9月7日 15:05:51
-                if (i > 0 && parseInt(r.lapQty) <= parseInt(item.replies[i - 1].lapQty) || r.lapQty == null) {
-                    valid = false;
-                    validLapQty = r.lapQty;
-                }
-            });
-            item.replies = replies;
-            $scope.loading = true;
-            if (!valid) {
-                if (validLapQty) {
-                    toaster.pop('info', '提示', '分段' + validLapQty + '小于等于了上一分段数,不能保存!');
-                } else {
-                    toaster.pop('info', '提示', '分段数量不合法,不能保存!');
-                }
-                $scope.loading = false;
-            } else {
-                var file = item.myFiles, file = file && file.length > 0 ? file[0] : null;
-                if (withSteps) { // 保存并报价
-                    if(null != file) {
-                        $upload.upload({
-                            url: 'sale/pubInquiry/addAttach',
-                            file: file,
-                            method: 'POST',
-                            data: {
-                                item: item,
-                                method: 'reply'
-                            }
-                        }).success(function (data) {
-                            if (data.item) {
-                                item = data.item;
-                            }
-                            $scope.loading = false;
-                            toaster.pop('info', '提示', '报价成功');
-                            $scope.tableParams.reload();
-                        }).error(function (data) {
-                            $scope.loading = false;
-                            toaster.pop('error', '附件上传失败');
-                        });
-                    } else {
-                        publicInquiry.reply({itemId: item.id, token: $scope.token}, item, function (data) {
-                            $scope.loading = false;
-                            toaster.pop('info', '提示', '报价成功');
-                            $scope.tableParams.reload();
-                        }, function (response) {
-                            $scope.loading = false;
-                            toaster.pop('error', '询价失效', response.data);
-                        });
-                    }
-                } else {  // 保存
-                    if(null != file) {
-                        $upload.upload({
-                            url: 'sale/pubInquiry/addAttach',
-                            file: file,
-                            method: 'POST',
-                            data: {
-                                item: item,
-                                method: 'save'
-                            }
-                        }).success(function (data) {
-                            if (data.item) {
-                                item = data.item;
-                            }
-                            $scope.loading = false;
-                            toaster.pop('info', '提示', '保存成功');
-                            $scope.tableParams.reload();
-                        }).error(function (data) {
-                            $scope.loading = false;
-                            toaster.pop('error', '附件上传失败');
-                        });
-                    } else {
-                        publicInquiry.saveItem({itemId: item.id, token: $scope.token}, item, function (data) {
-                            $scope.loading = false;
-                            toaster.pop('info', '提示', '保存成功');
-                            $scope.tableParams.reload();
-                        }, function (response) {
-                            $scope.loading = false;
-                            toaster.pop('error', '保存失败', response.data);
-                        });
-                    }
+        }, {
+            total: 0,
+            counts: [5, 10, 25, 50],
+            getData: function ($defer, params) {
+                $scope.loading = true;
+                var pageParams = params.url();
+                pageParams.searchFilter = { // 筛选条件
+                    keyword: $scope.keyword,
+                    fromDate: getDateTime($scope.condition.dateFrom),
+                    endDate: getDateTime($scope.condition.dateTo)
+                };
+                if ($scope.active == 'overdue') {
+                    $scope.active = 'end';
                 }
                 }
+                AccountEnterprise.get({}, function(data) {
+                    $scope.currentEn = data;
+                    publicInquiry.getUrl({}, function(data) {
+                        var url = data.url;
+                        $scope.url = url;
+                        if ($scope.active == 'todoComRemind') {// 企业商机
+                            AuthenticationService.getAuthentication().success(function (data) {
+                                $scope.loading = false;
+                                $scope.thisUser = data;
+                                $http({
+                                    method: 'get',
+                                    dataType: 'json',
+                                    url: url + '/inquiry/sale/enremind',
+                                    params: {
+                                        pageNumber: pageParams.page,
+                                        pageSize: pageParams.count,
+                                        useruu: $scope.thisUser.userUU,
+                                        enuu: $scope.currentEn.uu,
+                                        keyword: $scope.keyword,
+                                        fromDate: getDateTime($scope.condition.dateFrom),
+                                        endDate: getDateTime($scope.condition.dateTo)
+                                    }
+                                }).success(function (response) {
+                                    $scope.loading = false;
+                                    if (response) {
+                                        params.total(response.totalElements);
+                                        $defer.resolve(response.content);
+                                        $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
+                                    }
+                                }).error(function (err) {
+                                    $scope.loading = false;
+                                    toaster.pop('error', '数据加载失败', err);
+                                });
+                            });
+                        } else if ($scope.active == 'todoRemind') {// 推荐报价信息
+                            AuthenticationService.getAuthentication().success(function (data) {
+                                $scope.loading = false;
+                                $scope.thisUser = data;
+                                $http({
+                                    method: 'get',
+                                    dataType: 'json',
+                                    url: url + '/inquiry/sale/remind',
+                                    params: {pageNumber: pageParams.page, pageSize: pageParams.count, useruu: $scope.thisUser.userUU, enuu: $scope.currentEn.uu,
+                                        keyword: $scope.keyword, fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)}
+                                }).success(function (response) {
+                                    $scope.loading = false;
+                                    if (response) {
+                                        params.total(response.totalElements);
+                                        $defer.resolve(response.content);
+                                        $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
+                                    }
+                                }).error(function (err) {
+                                    $scope.loading = false;
+                                    toaster.pop('error', '数据加载失败', err);
+                                });
+                            });
+                        } else if ($scope.active == 'todoAll') {// 全部
+                            $http({
+                                method: 'get',
+                                dataType: 'json',
+                                url: url + '/inquiry/public',
+                                params: {pageNumber: pageParams.page, pageSize: pageParams.count, enUU: $scope.currentEn.uu, keyword: $scope.keyword,
+                                    fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo), distribute: $scope.distribute, remind: $scope.remind}
+                            }).success(function (response) {
+                                $scope.loading = false;
+                                if (response) {
+                                    params.total(response.totalElements);
+                                    $defer.resolve(response.content);
+                                    $scope.searchFilterXls = angular.copy(pageParams.searchFilter);//保存当前取值的关键词
+                                }
+                            }).error(function (err) {
+                                $scope.loading = false;
+                                toaster.pop('error', '数据加载失败', err);
+                            });
+                        } else {
+                            var filter = {vendUU: $scope.currentEn.uu, keyword: $scope.keyword,
+                                fromDate: getDateTime($scope.condition.dateFrom), endDate: getDateTime($scope.condition.dateTo)};
+                            $http({
+                                method: 'get',
+                                dataType: 'json',
+                                url: url + '/inquiry/public/quotation/list',
+                                params: {pageNumber: pageParams.page, pageSize: pageParams.count, filter: filter, _state: $scope.active}
+                            }).success(function (response) {
+                                $scope.loading = false;
+                                if (response) {
+                                    params.total(response.totalElements);
+                                    $defer.resolve(response.content);
+                                }
+                            }).error(function (err) {
+                                $scope.loading = false;
+                                toaster.pop('error', '数据加载失败', err);
+                            });
+                        }
+                    });
+                });
             }
             }
-        };
-
-        $scope.isValid = function (item, withSteps) {
-            var bool = item.leadtime && item.replies && item.replies[0].price > 0;
-            if (!withSteps || !bool)
-                return bool;
-            angular.forEach(item.replies, function (r, i) {
-                $scope.verifylapQty(r.lapQty, i, item);
-                bool = (i > 0 ? r.lapQty : 1) && r.price && $scope.replylapQtys[i];
-            });
-            return bool;
-        };
+        });
 
 
-        $scope.verifylapQty = function (value, index, inquiryItem) {
-            value = parseInt(value);
-            var regex = /^\d+(.\d{1,5})?$/;
-            var valid = true;
-            angular.forEach(inquiryItem.replies, function(reply, $index) {
-                if ($index < index && reply.lapQty >= value) {
-                    valid = false;
-                }
-            });
-            $scope.replylapQtys[index] = regex.test(value) && valid;
+        $scope.getMinDate = function (item) {
+            return $filter('date')(item.inquiry.date, 'yyyy-MM-dd');
         };
         };
 
 
-        $scope.minOrderQtyVerify = $scope.minPackQtyVerify = $scope.leadtimeVerify = true;
-        $scope.verify = function (value, type) {
-            var regex = /^\d+(.\d{1,6})?$/;//
-            switch (type) {
-                case 'minOrderQty':
-                    $scope.minOrderQtyVerify = regex.test(value);
-                    break;
-                case 'minPackQty':
-                    $scope.minPackQtyVerify = regex.test(value);
-                    break;
-                case 'leadtime':
-                    $scope.leadtimeVerify = regex.test(value);
-                    break;
-                default:
-                    $scope.replyPrices[type] = regex.test(value);
-                    break;
-            }
-        }
         // 搜索框回车
         // 搜索框回车
         $scope.onSearch = function (keyword) {
         $scope.onSearch = function (keyword) {
             // 每次搜索重置获取数据方法
             // 每次搜索重置获取数据方法
@@ -23261,6 +22791,124 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                 toaster.pop('error', '数据加载失败', response.data);
                 toaster.pop('error', '数据加载失败', response.data);
             })
             })
         }
         }
+
+        $scope.isOverDue = function (date) {
+            if (date) {
+                var ndate = new Date();
+                ndate.setHours(23, 59, 59 ,999);
+                ndate.setDate(ndate.getDate());
+                var timestamp = Date.parse(ndate);
+                if (date > timestamp) {
+                    return true;
+                } else {
+                    return false;
+                }
+            } else {
+                return true;
+            }
+        }
+
+        $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
+
+        customer.distribute({}, function(data) {
+            $scope.customer = data;
+        });
+
+        $scope.toDetail = function (item) {
+            if (item.quoted == 0) {
+                window.location.hash = '#/baseInfo/inquiryList/' + item.id;
+            } else {
+                window.open("#/sale/pubinquiry/" + item.quteId);
+            }
+        };
+
+        // 转客户询价
+        $scope.qute = function (remind) {
+            $http({
+                method: 'get',
+                dataType: 'json',
+                url: $scope.url + '/inquiry/sale/quote',
+                params: {id: remind.itemId, en_uu: $scope.currentEn.uu}
+            }).success(function (response) {
+                $scope.loading = false;
+                if (response.inquiry != null) {
+                    toaster.pop('error', '该单据已报价');
+                } else {
+                    $http({
+                        method: 'get',
+                        dataType: 'json',
+                        url: $scope.url + '/inquiry/public/findItemByItemId',
+                        params: {itemId: remind.itemId, enuu: $scope.currentEn.uu}
+                    }).success(function (response) {
+                        var inquiryItem = response;
+                        var modalInstance = $modal.open({
+                            templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
+                            controller: 'QuoteCtrl',
+                            size: 'lg',
+                            resolve: {
+                                inquiryItem: function () {
+                                    return inquiryItem
+                                }
+                            }
+                        });
+
+                        modalInstance.result.then(function (data) {
+                            $scope.tableParams.reload();
+                        }, function () {
+
+                        });
+                    }).error(function (error) {
+                        toaster.pop('error', '数据加载失败', error);
+                    });
+                }
+            }).error(function (err) {
+                toaster.pop('error', '数据加载失败', err);
+            });
+        }
+
+        // 跳转详情
+        $scope.remindDetail = function(remind) {
+            if (remind.newId == null) {
+                window.location.hash = '#/baseInfo/inquiryList/' + remind.itemId;
+            } else {
+                window.open("#/sale/pubinquiry/" + remind.newId);
+            }
+        }
+
+        // 搜索框回车
+        $scope.onSearch = function () {
+            $scope.tableParams.page(1);
+            $scope.tableParams.reload();
+        };
+
+        // 转客户询价
+        $scope.transtoInquiry = function (inquiryItem) {
+            if ($scope.currentEn.uu == inquiryItem.inquiry.enUU) {
+                toaster.pop('warning', '不能对自己企业报价');
+            } else {
+                var modalInstance = $modal.open({
+                    templateUrl: 'static/tpl/index/baseInfo/modal/quotation_modal.html',
+                    controller: 'QuoteCtrl',
+                    size: 'lg',
+                    resolve: {
+                        inquiryItem: function () {
+                            return inquiryItem
+                        }
+                    }
+                });
+
+                modalInstance.result.then(function (data) {
+                    $scope.tableParams.reload();
+                }, function () {
+
+                });
+            }
+        }
+
+        // 跳转到我的报价列表
+        $scope.linkToInquiry = function () {
+            window.open("#/sale/pubinquiry");
+        }
     }]);
     }]);
 
 
     /**
     /**

+ 206 - 9
src/main/webapp/resources/tpl/index/sale/pubinquiry.html

@@ -199,14 +199,14 @@
 						<button type="button" class="btn btn-default btn-line"
 						<button type="button" class="btn btn-default btn-line"
 								ng-class="{'btn-info':active=='all'}" ng-click="setActive('all')">全部<b class="new-dot" ng-if="unread.all>0">{{unread.all>99?'99+':unread.all}}</b></button>
 								ng-class="{'btn-info':active=='all'}" ng-click="setActive('all')">全部<b class="new-dot" ng-if="unread.all>0">{{unread.all>99?'99+':unread.all}}</b></button>
 					</div>
 					</div>
+                    <div class="btn-group btn-group-sm">
+                        <button type="button" class="btn btn-default btn-line"
+                                ng-class="{'btn-info':active=='todoAll' || active=='todoComRemind' || active=='todoRemind'}" ng-click="setActive('todoComRemind')">待报价</button>
+                    </div>
 					<div class="btn-group btn-group-sm">
 					<div class="btn-group btn-group-sm">
 						<button type="button" class="btn btn-default btn-line"
 						<button type="button" class="btn btn-default btn-line"
 								ng-class="{'btn-info':active=='done'}" ng-click="setActive('done');setOrdersReadByState()">已报价<b class="new-dot" ng-if="unread.replied>0">{{unread.replied>99?'99+':unread.replied}}</b></button>
 								ng-class="{'btn-info':active=='done'}" ng-click="setActive('done');setOrdersReadByState()">已报价<b class="new-dot" ng-if="unread.replied>0">{{unread.replied>99?'99+':unread.replied}}</b></button>
 					</div>
 					</div>
-					<!--<div class="btn-group btn-group-sm">
-						<button type="button" class="btn btn-default btn-line"
-								ng-class="{'btn-info':active=='todo'}" ng-click="setActive('todo')">待报价<b class="new-dot" ng-if="unread.notReply>0">{{unread.notReply>99?'99+':unread.notReply}}</b></button>
-					</div>-->
 					<div class="btn-group btn-group-sm">
 					<div class="btn-group btn-group-sm">
 						<button type="button" class="btn btn-default btn-line"
 						<button type="button" class="btn btn-default btn-line"
 								ng-class="{'btn-info':active=='agreed'}" ng-click="setActive('agreed')">已采纳</button>
 								ng-class="{'btn-info':active=='agreed'}" ng-click="setActive('agreed')">已采纳</button>
@@ -289,6 +289,24 @@
 			</div>
 			</div>
 		</div>
 		</div>
 	</div>
 	</div>
+    <div class="menu condition block">
+        <div class="col-xs-4">
+            <div class="btn-group btn-group-sm btn-group-justified">
+                <div class="btn-group btn-group-sm">
+                    <button type="button" class="btn btn-default btn-line"
+                            ng-class="{'btn-info':active=='todoAll'}" ng-click="setActive('todoAll')">全部</button>
+                </div>
+                <div class="btn-group btn-group-sm">
+                    <button type="button" class="btn btn-default btn-line"
+                            ng-class="{'btn-info':active=='todoRemind'}" ng-click="setActive('todoRemind')">我的商机</button>
+                </div>
+                <div class="btn-group btn-group-sm">
+                    <button type="button" class="btn btn-default btn-line"
+                            ng-class="{'btn-info':active=='todoComRemind'}" ng-click="setActive('todoComRemind')">企业商机</button>
+                </div>
+            </div>
+        </div>
+    </div>
 	<table class="order-table block" ng-table="tableParams">
 	<table class="order-table block" ng-table="tableParams">
 		<thead>
 		<thead>
 		<tr class="header">
 		<tr class="header">
@@ -303,6 +321,7 @@
 			<td colspan="6"></td>
 			<td colspan="6"></td>
 		</tr>
 		</tr>
 		</thead>
 		</thead>
+        <!-- 没有数据返回-->
 		<tbody ng-if="tableParams.total() == 0">
 		<tbody ng-if="tableParams.total() == 0">
 		<tr>
 		<tr>
 			<td colspan="6">
 			<td colspan="6">
@@ -341,7 +360,8 @@
 			</td>
 			</td>
 		</tr>
 		</tr>
 		</tbody>
 		</tbody>
-		<tbody ng-repeat="inquiryItem in $data track by inquiryItem.id">
+        <!--客户询价信息 start-->
+		<tbody ng-if="active != 'todoAll' && active != 'todoRemind' && active != 'todoComRemind'" ng-repeat="inquiryItem in $data track by inquiryItem.id">
 		<tr class="order-hd">
 		<tr class="order-hd">
 			<td class="first" colspan="2">
 			<td class="first" colspan="2">
 				<div class="order-main">
 				<div class="order-main">
@@ -349,8 +369,7 @@
 						  ng-bind="::inquiryItem.inquiry.date | date:'yyyy-MM-dd'"></span>
 						  ng-bind="::inquiryItem.inquiry.date | date:'yyyy-MM-dd'"></span>
 					<span ng-bind="::inquiryItem.inquiry.enterprise.enName"></span>
 					<span ng-bind="::inquiryItem.inquiry.enterprise.enName"></span>
 					<span>流水号:
 					<span>流水号:
-						<a title="查看详情"
-						   class="text-num order-detail"
+						<a title="查看详情" class="text-num order-detail"
 						   ng-bind="::inquiryItem.inquiry.code"
 						   ng-bind="::inquiryItem.inquiry.code"
 						   ui-sref="sale.pubinquiry_detail({id:inquiryItem.id})"
 						   ui-sref="sale.pubinquiry_detail({id:inquiryItem.id})"
 						   target="_self"
 						   target="_self"
@@ -374,8 +393,7 @@
 		<tr class="order-bd">
 		<tr class="order-bd">
 			<td class="product">
 			<td class="product">
 				<div class="text-num text-bold">
 				<div class="text-num text-bold">
-					<a class="dropdown-toggle"
-					   ng-mouseover="getHistory(inquiryItem)">
+					<a class="dropdown-toggle">
 						<span ng-bind="::inquiryItem.product.cmpCode || inquiryItem.cmpCode"></span>
 						<span ng-bind="::inquiryItem.product.cmpCode || inquiryItem.cmpCode"></span>
 						<i class="fa fa-fw fa-sort-desc"></i>
 						<i class="fa fa-fw fa-sort-desc"></i>
 						<div class="dropdown-menu pane" style="width: 270px;">
 						<div class="dropdown-menu pane" style="width: 270px;">
@@ -443,5 +461,184 @@
 			</td>
 			</td>
 		</tr>
 		</tr>
 		</tbody>
 		</tbody>
+        <!--客户询价信息 end-->
+        <!--公共询价全部 start-->
+        <tbody ng-if="active == 'todoAll'" ng-repeat="inquiryItem in $data track by inquiryItem.id">
+        <tr class="order-hd">
+            <td class="first" colspan="2">
+                <div class="order-main">
+					<span class="text-num text-bold" title="{{inquiryItem.inquiry.date}}"
+                          ng-bind="::inquiryItem.inquiry.date | date:'yyyy-MM-dd'"></span>
+                    <span ng-bind="::inquiryItem.inquiry.enterprise.enName"></span>
+                    <span>流水号:
+						<a title="查看详情" class="text-num order-detail"
+                           ng-bind="::inquiryItem.inquiry.code"
+                           target="_self"
+                           ng-click="toDetail(inquiryItem)"></a>
+					</span>
+                </div>
+            </td>
+            <td>
+                币别:<span ng-bind="::(isUser?'-':inquiryItem.currency)"></span>
+            </td>
+            <td>
+                税率:<span>17</span>%
+            </td>
+            <td class="text-right" colspan="2" class="order-sum">
+                <div ng-if="inquiryItem.replyable">
+                    <span class="text-inverse text-bold" ng-bind="::inquiryItem.inquiry.endDate | timespan"></span>
+                    <span class="text-muted" style="margin-right:35px;">后截止报价</span>
+                </div>
+            </td>
+        </tr>
+        <tr class="order-bd">
+            <td class="product">
+                <div class="text-num text-bold">
+                    <a class="dropdown-toggle">
+                        <span ng-bind="::inquiryItem.product.cmpCode || inquiryItem.cmpCode"></span>
+                        <i class="fa fa-fw fa-sort-desc"></i>
+                        <div class="dropdown-menu pane" style="width: 270px;">
+                            <div class="pane-body">
+                                <div>
+                                    <div>
+                                        <span>产品规格:</span>
+                                        <em ng-bind="inquiryItem.product.spec || inquiryItem.spec || '无'"></em>
+                                    </div>
+                                    <div>
+                                        <span>产品名称:</span>
+                                        <em ng-bind="::inquiryItem.product.title || inquiryItem.prodTitle || '无'"></em>
+                                    </div>
+                                </div>
+                                <div ng-show="!inquiryItem.product.spec && !inquiryItem.product.title && !inquiryItem.spec && !inquiryItem.prodTitle"
+                                     class="text-center text-muted">暂无产品信息</div>
+                            </div>
+                        </div>
+                    </a>
+                </div>
+                <div ng-if="inquiryItem.attachUrl" class="text-muted">
+                    <i class="fa fa-paperclip fa-fw" style="color: #ffa340; font-size: 18px;"></i>附件:<a class="file" href="{{inquiryItem.attachUrl}}" target="_blank">{{::inquiryItem.attachName}}</a>
+                </div>
+            </td>
+            <td class="text-center">
+                <span ng-bind="inquiryItem.product.brand || inquiryItem.inbrand || '-'"></span>
+            </td>
+            <td class="text-center">
+                <div ng-repeat="reply in inquiryItem.replies">
+                    <span ng-bind="reply.lapQty"></span>
+                </div>
+            </td>
+            <td class="text-center">
+                <div ng-repeat="reply in inquiryItem.replies">
+                    <span ng-bind="isUser?'':(reply.price | number:6)"></span>
+                    <span ng-show="reply.price == null || isUser" class="text-muted">-</span>
+                </div>
+            </td>
+            <td class="text-center">
+                <span ng-bind="inquiryItem.minOrderQty ? inquiryItem.minOrderQty : '-'"></span>
+                <span>/</span>
+                <span ng-bind="inquiryItem.minPackQty ? inquiryItem.minPackQty : '-'"></span>
+            </td>
+            <td ng-if="inquiryItem.quoted == 1">
+                <a class="offer" ng-click="">已报价</a>
+            </td>
+            <td ng-if="inquiryItem.quoted != 1">
+                <a class="offer"ng-click="transtoInquiry(inquiryItem)" ng-if="inquiryItem.remainingTime > 0 && inquiryItem.overdue != 1 && currentEn.uu != inquiryItem.inquiry.enUU">主动报价</a>
+                <a style="color: #999" ng-if="currentEn.uu == inquiryItem.inquiry.enUU" ng-click="transtoInquiry(inquiryItem)">主动报价</a>
+                <a class="offer" ng-if="inquiryItem.remainingTime <= 0 || inquiryItem.overdue == 1 || !isOverDue(inquiryItem.inquiry.endDate)" ng-click="">已结束</a>
+            </td>
+        </tr>
+        </tbody>
+        <!--公共询价全部 end-->
+        <!--商机 start-->
+        <tbody ng-if="active == 'todoRemind' || active == 'todoComRemind'" ng-repeat="inquiryItem in $data track by inquiryItem.id">
+        <tr class="order-hd">
+            <td class="first" colspan="2">
+                <div class="order-main">
+					<span class="text-num text-bold" title="{{inquiryItem.inquiry.date}}"
+                          ng-bind="::inquiryItem.inquiry.date | date:'yyyy-MM-dd'"></span>
+                    <span ng-bind="::inquiryItem.inquiry.enterprise.enName"></span>
+                    <span>流水号:
+						<a title="查看详情" class="text-num order-detail"
+                           ng-bind="::inquiryItem.inquiry.code"
+                           target="_self"
+                           ng-click="remindDetail(inquiryItem)"></a>
+					</span>
+                </div>
+            </td>
+            <td>
+                币别:<span ng-bind="::(isUser?'-':inquiryItem.currency)"></span>
+            </td>
+            <td>
+                税率:<span>17</span>%
+            </td>
+            <td class="text-right" colspan="2" class="order-sum">
+                <div ng-if="inquiryItem.replyable">
+                    <span class="text-inverse text-bold" ng-bind="::inquiryItem.inquiry.endDate | timespan"></span>
+                    <span class="text-muted" style="margin-right:35px;">后截止报价</span>
+                </div>
+            </td>
+        </tr>
+        <tr class="order-bd">
+            <td class="product">
+                <div class="text-num text-bold">
+                    <a class="dropdown-toggle">
+                        <span ng-bind="::inquiryItem.product.cmpCode || inquiryItem.cmpCode"></span>
+                        <i class="fa fa-fw fa-sort-desc"></i>
+                        <div class="dropdown-menu pane" style="width: 270px;">
+                            <div class="pane-body">
+                                <div>
+                                    <div>
+                                        <span>产品规格:</span>
+                                        <em ng-bind="inquiryItem.product.spec || inquiryItem.spec || '无'"></em>
+                                    </div>
+                                    <div>
+                                        <span>产品名称:</span>
+                                        <em ng-bind="::inquiryItem.product.title || inquiryItem.prodTitle || '无'"></em>
+                                    </div>
+                                </div>
+                                <div ng-show="!inquiryItem.product.spec && !inquiryItem.product.title && !inquiryItem.spec && !inquiryItem.prodTitle"
+                                     class="text-center text-muted">暂无产品信息</div>
+                            </div>
+                        </div>
+                    </a>
+                </div>
+                <div ng-if="inquiryItem.attachUrl" class="text-muted">
+                    <i class="fa fa-paperclip fa-fw" style="color: #ffa340; font-size: 18px;"></i>附件:<a class="file" href="{{inquiryItem.attachUrl}}" target="_blank">{{::inquiryItem.attachName}}</a>
+                </div>
+            </td>
+            <td class="text-center">
+                <span ng-bind="inquiryItem.product.brand || inquiryItem.inbrand || '-'"></span>
+            </td>
+            <td class="text-center">
+                <div ng-repeat="reply in inquiryItem.replies">
+                    <span ng-bind="reply.lapQty"></span>
+                </div>
+            </td>
+            <td class="text-center">
+                <div ng-repeat="reply in inquiryItem.replies">
+                    <span ng-bind="isUser?'':(reply.price | number:6)"></span>
+                    <span ng-show="reply.price == null || isUser" class="text-muted">-</span>
+                </div>
+            </td>
+            <td class="text-center">
+                <span ng-bind="inquiryItem.minOrderQty ? inquiryItem.minOrderQty : '-'"></span>
+                <span>/</span>
+                <span ng-bind="inquiryItem.minPackQty ? inquiryItem.minPackQty : '-'"></span>
+            </td>
+            <td>
+                <div ng-if="inquiryItem.remainingTime <= 0" class="block">
+                    <span>已结束</span>
+                </div>
+                <div ng-if="inquiryItem.remainingTime > 0" class="block">
+                    <a ng-if="inquiryItem.status==100" ng-click="qute(inquiryItem)">报价</a>
+                    <span ng-if="inquiryItem.status==101">已报价</span>
+                    <span ng-if="inquiryItem.status==104">已采纳</span>
+                    <span ng-if="inquiryItem.status==103">未采纳</span>
+                    <span ng-if="inquiryItem.status==111">已结束</span>
+                </div>
+            </td>
+        </tr>
+        </tbody>
+        <!--商机 end-->
 	</table>
 	</table>
 </div>
 </div>