Pārlūkot izejas kodu

公共询价列表增加展示的数据:我的客户询价,推荐询价;页面截止时间展示方法更新

hejq 8 gadi atpakaļ
vecāks
revīzija
a0b9f71e88

+ 10 - 0
src/main/java/com/uas/platform/b2b/controller/CustomerController.java

@@ -129,4 +129,14 @@ public class CustomerController {
 		return customerService.findAllByCustUU(user.getEnterprise().getUu(), custUU);
 	}
 
+    /**
+     * 获取分配的客户信息
+     *
+     * @return
+     */
+	@RequestMapping(value = "/distribute", method = RequestMethod.GET)
+    @ResponseBody
+    public List<Long> getCustomerDistribute() {
+	    return customerService.getCustomerDistribute();
+    }
 }

+ 7 - 0
src/main/java/com/uas/platform/b2b/service/CustomerService.java

@@ -114,4 +114,11 @@ public interface CustomerService {
 	List<Object[]> getCustomerCount(String sale);
 
 	List<Long> getUnreadIds(String sale);
+
+	/**
+	 * 获取当前用户所分配的客户信息
+	 *
+	 * @return
+	 */
+    List<Long> getCustomerDistribute();
 }

+ 47 - 2
src/main/java/com/uas/platform/b2b/service/impl/CustomerServiceImpl.java

@@ -2,9 +2,10 @@ package com.uas.platform.b2b.service.impl;
 
 import com.uas.platform.b2b.dao.CustomerDao;
 import com.uas.platform.b2b.dao.UserOrderDao;
-import com.uas.platform.b2b.model.Customer;
-import com.uas.platform.b2b.model.User;
+import com.uas.platform.b2b.dao.VendorDao;
+import com.uas.platform.b2b.model.*;
 import com.uas.platform.b2b.service.CustomerService;
+import com.uas.platform.b2b.service.UserService;
 import com.uas.platform.b2b.support.SystemSession;
 import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.persistence.criteria.PredicateFactory;
@@ -21,6 +22,7 @@ import javax.persistence.criteria.Predicate;
 import javax.persistence.criteria.Root;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Set;
 
 @Service
 public class CustomerServiceImpl implements CustomerService {
@@ -31,6 +33,12 @@ public class CustomerServiceImpl implements CustomerService {
 	@Autowired
 	private UserOrderDao userOrderDao;
 
+	@Autowired
+    private UserService userService;
+
+	@Autowired
+    private VendorDao vendorDao;
+
 	public Page<Customer> findAllByPageInfo(final Long enUU, final PageInfo pageInfo) {
 		Page<Customer> customers = customerDao.findAll(new Specification<Customer>() {
 
@@ -117,4 +125,41 @@ public class CustomerServiceImpl implements CustomerService {
 		return userOrderDao.getUnreadIds(SystemSession.getUser().getEnterprise().getUu(), SystemSession.getUser().getUserUU(), "sale$customers", category);
 	}
 
+	/**
+	 * 获取当前用户所分配的客户信息
+	 *
+	 * @return
+	 */
+	@Override
+	public List<Long> getCustomerDistribute() {
+        List<Long> distributes = new ArrayList<Long>();
+        Set<Role> roles = SystemSession.getUser().getRoles();
+        boolean isSys = false;
+        for (Role role : roles) {
+            if (role.getIssys() == 1) {
+                isSys = true;
+                break;
+            }
+            if ("ROLE_SALEMANAGER".equals(role.getName())) {
+                isSys = true;
+                break;
+            }
+        }
+        if (!SystemSession.getUser().isSys() && !isSys) {
+            List<Vendor> vendors = userService.findChooseVendor(SystemSession.getUser().getUserUU());
+            if (!CollectionUtils.isEmpty(vendors)) {
+                for (Vendor v : vendors) {
+                    distributes.add(v.getMyEnUU());
+                }
+            }
+        } else if (SystemSession.getUser().isSys() || isSys) {
+            List<Vendor> vendors = vendorDao.findByVendEnUU(SystemSession.getUser().getEnterprise().getUu());
+            if (!CollectionUtils.isEmpty(vendors)) {
+                for (Vendor v : vendors) {
+                    distributes.add(v.getMyEnUU());
+                }
+            }
+        }
+        return distributes;
+	}
 }

+ 114 - 47
src/main/webapp/resources/js/index/app.js

@@ -1,6 +1,6 @@
-define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives', 'service/Purc', 'service/Make', 'service/Fa', 'service/Account', 'service/Alert', 'service/CheckTel', 'ui.router', 'ui.bootstrap', 'file-upload', 'ngSanitize', 'service/BaseInfo', 'service/Cart', 'service/ApprovalFlow', 'service/DeputyOrder', 'service/Product', 'service/Token', 'service/ProductUsers', 'service/File', 'service/PublicInquiry'], function () {
+define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives', 'service/Purc', 'service/Make', 'service/Fa', 'service/Account', 'service/Alert', 'service/CheckTel', 'ui.router', 'ui.bootstrap', 'file-upload', 'ngSanitize', 'service/BaseInfo', 'service/Cart', 'service/ApprovalFlow', 'service/DeputyOrder', 'service/Product', 'service/Token', 'service/ProductUsers', 'service/File', 'service/PublicInquiry', 'service/Customer'], function () {
     'use strict';
-    var app = angular.module('myApp', ['toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'common.directives', 'PurcServices', 'MakeServices', 'FaServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize', 'CheckTelModule', 'ProductServices', 'CartServices', 'ApprvoalFlowService', 'DeputyOrderService', 'ProductInfoServices', 'TokenService', 'ProductUserService', 'ui.tour', 'FileService', 'publicInquiryService']);
+    var app = angular.module('myApp', ['toaster', 'angularCharts', 'ngTable', 'ui.router', 'common.services', 'common.directives', 'PurcServices', 'MakeServices', 'FaServices', 'AccountServices', 'AlertServices', 'ui.bootstrap', 'angularFileUpload', 'ngSanitize', 'CheckTelModule', 'ProductServices', 'CartServices', 'ApprvoalFlowService', 'DeputyOrderService', 'ProductInfoServices', 'TokenService', 'ProductUserService', 'ui.tour', 'FileService', 'publicInquiryService', 'CustomerService']);
     app.init = function () {
         angular.bootstrap(document, ['myApp']);
     };
@@ -5400,7 +5400,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     }]);
 
     // 公共询价列表
-    app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', 'publicInquiry', 'publicInquiryList', '$modal', '$http', 'AccountEnterprise', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry, publicInquiry, publicInquiryList, $modal, $http, AccountEnterprise) {
+    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();
         /**
          * 改变单据日期范围
@@ -5483,7 +5483,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         };
 
         $scope.nowdate = new Date().getTime() - 24 * 3600 * 1000;
-        var getOpenState = function (active) {
+        var getState = function (active) {
             var fn = 'getOpenAll';
             switch (active) {
                 case 'all':
@@ -5499,9 +5499,25 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             return fn;
         };
 
+        customer.distribute({}, function(data) {
+           $scope.customer = data;
+        });
+
         $scope.setActive = function (state) {
             if ($scope.active != state) {
                 $scope.active = state;
+                if ($scope.active == 'all') {
+                    $scope.distribute = null;
+                    $scope.remind = false;
+                } else if ($scope.active == 'customer') {
+                    $scope.distribute = $scope.customer;
+                    if ($scope.distribute.length == 0) {
+                        $scope.distribute = [1];
+                    }
+                    $scope.remind = false;
+                } else if ($scope.active == 'remind') {
+                    $scope.remind = true;
+                }
                 if ($scope.tableParams.page() == 1) {
                     $scope.tableParams.reload();
                 } else {
@@ -5534,38 +5550,50 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
                     fromDate: getDateTime($scope.condition.dateFrom),
                     endDate: getDateTime($scope.condition.dateTo)
                 };
-                /*getService().call(null, BaseService.parseParams(pageParams), function (page) {
-                 $scope.loading = false;
-                 if (page) {
-                 params.total(page.totalElement);
-                 $defer.resolve(page.content);
-                 // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词  做导出时需要的字段
-                 }
-                 }, function (response) {
-                 $scope.loading = false;
-                 toaster.pop('error', '数据加载失败', response.data);
-                 });*/
+
                 AccountEnterprise.get({}, function(data) {
                    $scope.currentEn = data;
                     publicInquiry.getUrl({}, function(data) {
-                        var url = data.url;
-                        $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)}
-                        }).success(function (response) {
-                            $scope.loading = false;
-                            if (response) {
-                                params.total(response.totalElements);
-                                $defer.resolve(response.content);
-                                // $scope.keywordXls = angular.copy($scope.keyword); // 保存当前取值的关键词  做导出时需要的字段
-                            }
-                        }).error(function (err) {
-                            $scope.loading = false;
-                            toaster.pop('error', '数据加载失败', err);
-                        });
+                        $scope.url = data.url;
+                        if (!$scope.remind) {// 非推荐信息
+                            $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);
+                                }
+                            }).error(function (err) {
+                                $scope.loading = false;
+                                toaster.pop('error', '数据加载失败', err);
+                            });
+                        } else {// 推荐报价信息
+                            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);
+                                    }
+                                }).error(function (err) {
+                                    $scope.loading = false;
+                                    toaster.pop('error', '数据加载失败', err);
+                                });
+                            });
+                        }
 
                         // 顶部滚动消息
                         $http({
@@ -5591,6 +5619,59 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             }
         };
 
+        // 转客户询价
+        $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);
@@ -24391,20 +24472,6 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
             $scope.tableParams.reload();
         }
 
-        // 是否已过期
-        $scope.isOverDue = function (date) {
-            if (date) {
-                var timestamp = new Date().getTime() + 60000;
-                if (date > timestamp) {
-                    return false;
-                } else {
-                    return true;
-                }
-            } else {
-                return false;
-            }
-        }
-
         // 转客户询价
         $scope.qute = function (remind) {
             $http({

+ 14 - 0
src/main/webapp/resources/js/index/services/Customer.js

@@ -0,0 +1,14 @@
+define([ 'ngResource'], function() {
+	angular.module('CustomerService', [ 'ngResource']).factory('customer', ['$resource', function($resource) {
+		return $resource('customer', {}, {
+            /**
+             * 获取当前用户客户分配信息
+             */
+            distribute: {
+				url: 'sale/customers/distribute',
+				mehtod: 'GET',
+				isArray: true
+			}
+		})
+	}])
+});

+ 29 - 19
src/main/webapp/resources/tpl/index/baseInfo/inquiry_list.html

@@ -361,10 +361,9 @@
                             </div>
                             <div class="count">共<em ng-bind="tableParams.total()"></em>条</div>
                             <div class="all">
-                                <span ng-click="setActive('all'); changeDateZone(-1)" title="" ng-class="{'active': condition.dateZone == '-1'}" ><img src="static/img/all/bar.png" alt="" class="first"/>全部</span>
                                 <span class="history">
-                                    <span><img src="static/img/all/history.png" alt=""/>历史询价</span>
-                                    <ul>
+                                     <span ng-click="setActive('all'); changeDateZone(-1)" title="" ng-class="{'active': condition.dateZone == '-1'}" ><img src="static/img/all/bar.png" alt="" class="first"/>全部</span>
+                                     <ul>
                                         <li ng-click="changeDateZone(7)" title="" ng-class="{'active': condition.dateZone == '7'}">一周内</li>
                                         <li ng-click="changeDateZone(1)" title="" ng-class="{'active': condition.dateZone == '1'}">一个月内</li>
                                         <li ng-click="changeDateZone(3)" title="" ng-class="{'active': condition.dateZone == '3'}">三个月内</li>
@@ -372,7 +371,13 @@
                                         <li ng-click="changeDateZone()" title="" ng-class="{'active': condition.dateZone == null}">一年内</li>
                                     </ul>
                                 </span>
-                                <!--<span ng-click="setActive('teams')"><img src="static/img/all/money.png">我的报价</span>-->
+                                <span class="history">
+                                    <span><img src="static/img/all/bar.png" alt=""/>与我相关</span>
+                                    <ul>
+                                        <li ng-click="setActive('remind')" title="" ng-class="{'active': condition.dateZone == '7'}">推荐报价</li>
+                                        <li ng-click="setActive('customer')" title="" ng-class="{'active': condition.dateZone == '1'}">我的客户询价</li>
+                                    </ul>
+                                </span>
                                 <span ng-click="linkToInquiry()"><img src="static/img/all/money.png">我的报价</span>
                             </div>
                         </div>
@@ -391,7 +396,7 @@
                                    <th width="70" class="line"><em></em>报价</th>
                                </tr>
                                </thead>
-                               <tbody ng-if="active == 'all'">
+                               <tbody ng-if="active != 'remind'">
                                     <tr ng-repeat="inquiryItem in $data">
                                         <td ng-click="toDetail(inquiryItem)" title="查看详情" ng-bind="inquiryItem.inquiry.date| date: 'yyyy-MM-dd'"></td>
                                         <td ng-click="toDetail(inquiryItem)" title="查看详情" ng-bind="inquiryItem.product.brand || inquiryItem.inbrand || '无'"></td>
@@ -400,25 +405,30 @@
                                         <td ng-click="toDetail(inquiryItem)" title="查看详情" ng-bind="inquiryItem.product.spec || inquiryItem.spec || '无'"></td>
                                         <td ng-click="toDetail(inquiryItem)" title="查看详情" ng-bind="inquiryItem.needquantity"></td>
                                         <td ng-click="toDetail(inquiryItem)" title="查看详情" ng-bind="inquiryItem.inquiry.enterprise.enName"><a></a></td>
-                                        <td ng-click="toDetail(inquiryItem)" title="查看详情" ng-bind="inquiryItem.inquiry.endDate| date: 'yyyy-MM-dd'"></td>
+                                        <td ng-click="toDetail(inquiryItem)" title="查看详情" ng-bind="inquiryItem.inquiry.endDate| datespan"></td>
                                         <td>
-                                            <a class="offer"ng-click="transtoInquiry(inquiryItem)" ng-if="isOverDue(inquiryItem.inquiry.endDate) && inquiryItem.quoted != 1 && inquiryItem.overdue != 1">我要报价</a>
-                                            <a class="offer" ng-if="(!isOverDue(inquiryItem.inquiry.endDate) && inquiryItem.quoted != 1) || inquiryItem.overdue == 1" ng-click="">已结束</a>
+                                            <a class="offer"ng-click="transtoInquiry(inquiryItem)" ng-if="inquiryItem.remainingTime > 0 && inquiryItem.quoted != 1 && inquiryItem.overdue != 1">我要报价</a>
+                                            <a class="offer" ng-if="inquiryItem.remainingTime <= 0 && inquiryItem.quoted != 1) || inquiryItem.overdue == 1" ng-click="">已结束</a>
                                             <a class="offer" ng-if="inquiryItem.quoted == 1" ng-click="">已报价</a>
                                         </td>
                                     </tr>
                                </tbody>
-                               <tbody ng-if="active == 'teams'">
-                                   <tr ng-repeat="inquiryItem in $data" ui-sref="sale.inquiry_detail({id:inquiryItem.inquiry.id})" title="查看详情">
-                                       <td ng-bind="inquiryItem.inquiry.date| date: 'yyyy-MM-dd'"></td>
-                                       <td ng-bind="inquiryItem.product.brand || inquiryItem.inbrand"></td>
-                                       <td ng-bind="inquiryItem.product.title || inquiryItem.prodTitle"></td>
-                                       <td ng-bind="inquiryItem.product.cmpCode || inquiryItem.cmpCode"></td>
-                                       <td ng-bind="inquiryItem.product.spec || inquiryItem.spec"></td>
-                                       <td ng-bind="inquiryItem.needquantity"></td>
-                                       <td ng-bind="inquiryItem.inquiry.enterprise.enName"><a></a></td>
-                                       <td ng-bind="inquiryItem.inquiry.endDate| date: 'yyyy-MM-dd'"></td>
-                                       <td><a class="offer"  ui-sref="sale.inquiry_detail({id:inquiryItem.inquiry.id})">查看详情</a></td>
+                               <tbody ng-if="active == 'remind'">
+                                   <tr ng-repeat="remind in $data">
+                                       <td ng-click="remindDetail(remind)" title="查看详情" ng-bind="remind.reDate| date: 'yyyy-MM-dd'"></td>
+                                       <td ng-click="remindDetail(remind)" title="查看详情" ng-bind="remind.brand"></td>
+                                       <td ng-click="remindDetail(remind)" title="查看详情" ng-bind="remind.title"></td>
+                                       <td ng-click="remindDetail(remind)" title="查看详情" ng-bind="remind.cmpCode"></td>
+                                       <td ng-click="remindDetail(remind)" title="查看详情" ng-bind="remind.spec"></td>
+                                       <td ng-click="remindDetail(remind)" title="查看详情" ng-bind="remind.needQty"></td>
+                                       <td ng-click="remindDetail(remind)" title="查看详情" ng-bind="remind.enName"><a></a></td>
+                                       <td ng-click="remindDetail(remind)" title="查看详情" ng-bind="remind.endDate| datespan"></td>
+                                       <td>
+                                           <a ng-if="remind.status==100" ng-click="qute(remind)">报价</a>
+                                           <span ng-if="remind.status==101">已报价</span>
+                                           <span ng-if="remind.status==104">已采纳</span>
+                                           <span ng-if="remind.status==103">未采纳</span>
+                                       </td>
                                    </tr>
                                </tbody>
                            </table>