Prechádzať zdrojové kódy

询价方法更新,调用公共服务接口

hejq 8 rokov pred
rodič
commit
3b36b7f7fb

+ 100 - 0
src/main/java/com/uas/platform/b2b/controller/PubInquiryListController.java

@@ -0,0 +1,100 @@
+package com.uas.platform.b2b.controller;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2b.model.*;
+import com.uas.platform.b2b.service.EnquiryService;
+import com.uas.platform.b2b.support.UsageBufferedLogger;
+import com.uas.platform.core.logging.BufferedLoggerManager;
+import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.PageParams;
+import com.uas.search.b2b.model.SPage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.ui.ModelMap;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 首页公共询价列表数据
+ *
+ * Created by hejq on 2018-01-17.
+ */
+@RequestMapping("/pubInquiry")
+@RestController
+public class PubInquiryListController {
+
+    private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
+    @Autowired
+    private EnquiryService enquiryService;
+
+    /**
+     * 获取所有企业发布的公共询价列表信息
+     *
+     * @author hejq
+     * @date 2018-01-17 19:45
+     * @param params
+     * @param searchFilter
+     * @return
+     */
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    SPage<PurcInquiryItemInfo> getInquiryList(PageParams params, String searchFilter) throws Exception {
+        logger.log("公共询价单", "查看公共询价单列表");
+        PageInfo pageInfo = new PageInfo(params);
+        SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
+        return enquiryService.fingByPageInfo(pageInfo, filter);
+    }
+
+    /**
+     * 通过id查询公共询价详情
+     *
+     * @param id 询价明细id
+     * @return
+     */
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    private ModelMap getInquiryItemDetail(@PathVariable Long id) throws Exception {
+        logger.log("公共询价", "查看询价详情", "关联id:" + id);
+        return enquiryService.getInquiryItemDetail(id);
+    }
+
+    /**
+     * 转报价时查询是否已经转过报价
+     *
+     * @param id 公共询价id
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/quotation/{id}", method = RequestMethod.GET)
+    private ModelMap getQuotation(@PathVariable Long id) throws Exception {
+        logger.log("公共询价", "报价时查询报价信息", "关联id: " + id);
+        return enquiryService.getQuotation(id);
+    }
+
+    /**
+     * 通过报价id查询报价详情
+     *
+     * @param id 报价明细id
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/inquiry/{id}", method = RequestMethod.GET)
+    private ModelMap getInquiryDetail(@PathVariable Long id) throws Exception {
+        logger.log("公共询价", "查询报价详情", "关联id: " + id);
+        return enquiryService.getInquiryDetail(id);
+    }
+
+    /**
+     * 将客户询价单转成询价报价单
+     *
+     * @param item 报价信息
+     * @param method  方法
+     * @param uploadItem 附件
+     * @return
+     * @throws Exception
+     */
+    @RequestMapping(value = "/turnToQuotation", method = RequestMethod.POST)
+    private ModelMap turanToQuotation(String item, String method, FileUpload uploadItem) throws Exception {
+        PublicInquiryItem inquiryItem = JSON.parseObject(item, PublicInquiryItem.class);
+        logger.log("公共询价", "将公共询价转成客户询价单", "关联id:" + inquiryItem.getId());
+        return enquiryService.turnToQuotation(inquiryItem, method, uploadItem);
+    }
+}

+ 15 - 0
src/main/java/com/uas/platform/b2b/model/PublicInquiryItem.java

@@ -8,6 +8,7 @@ import org.codehaus.jackson.annotate.JsonIgnore;
 import org.springframework.util.CollectionUtils;
 
 import javax.persistence.*;
+import javax.transaction.Transactional;
 import java.io.Serializable;
 import java.util.*;
 
@@ -292,6 +293,12 @@ public class PublicInquiryItem implements Serializable {
 	@Column(name = "id_kind")
 	private String kind;
 
+	/**
+	 * 报价应用
+	 */
+	@Transient
+	private String quDomain;
+
 	public Long getId() {
 		return id;
 	}
@@ -615,6 +622,14 @@ public class PublicInquiryItem implements Serializable {
 		this.kind = kind;
 	}
 
+	public String getQuDomain() {
+		return quDomain;
+	}
+
+	public void setQuDomain(String quDomain) {
+		this.quDomain = quDomain;
+	}
+
 	/**
 	 * 回复记录的描述
 	 * 

+ 47 - 2
src/main/java/com/uas/platform/b2b/model/SearchFilter.java

@@ -13,35 +13,57 @@ public class SearchFilter {
 	 * 关键词
 	 */
 	private String keyword;
+
 	/**
 	 * 开始日期
 	 */
 	private Long fromDate;
+
 	/**
 	 * 结束日期
 	 */
 	private Long endDate;
+
 	/**
 	 * 开始交货日期
 	 */
 	private Long fromDelivery;
+
 	/**
 	 * 结束交货日期
 	 */
 	private Long endDelivery;
+
 	/**
 	 * 开始价格
 	 */
 	private Double fromPrice;
+
 	/**
 	 * 结束价格
 	 */
 	private Double endPrice;
+
 	/**
 	 * 客户分配条件
 	 */
 	private Collection<?> distribute;
-	
+
+	/**
+	 * 供应商UU
+	 */
+	private Long vendUU;
+
+	/**
+	 * 客户UU
+	 */
+	private Long enUU;
+
+	/**
+	 * 用户UU
+	 */
+	private Long userUU;
+
 	public String getKeyword() {
 		return keyword;
 	}
@@ -90,5 +112,28 @@ public class SearchFilter {
 	public void setDistribute(Collection<?> distribute) {
 		this.distribute = distribute;
 	}
-	
+
+	public Long getVendUU() {
+		return vendUU;
+	}
+
+	public void setVendUU(Long vendUU) {
+		this.vendUU = vendUU;
+	}
+
+	public Long getEnUU() {
+		return enUU;
+	}
+
+	public void setEnUU(Long enUU) {
+		this.enUU = enUU;
+	}
+
+	public Long getUserUU() {
+		return userUU;
+	}
+
+	public void setUserUU(Long userUU) {
+		this.userUU = userUU;
+	}
 }

+ 125 - 9
src/main/java/com/uas/platform/b2b/ps/InquiryUtils.java

@@ -1,12 +1,17 @@
 package com.uas.platform.b2b.ps;
 
 import com.alibaba.fastjson.JSON;
-import com.uas.platform.b2b.model.Attach;
-import com.uas.platform.b2b.model.PublicInquiry;
-import com.uas.platform.b2b.model.PublicInquiryItem;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.alibaba.fastjson.parser.Feature;
+import com.uas.account.support.Page;
+import com.uas.platform.b2b.model.*;
+import com.uas.platform.core.model.PageInfo;
 import com.uas.platform.core.util.HttpUtil;
 import com.uas.platform.core.util.serializer.FlexJsonUtils;
+import org.springframework.ui.ModelMap;
 
+import java.util.HashMap;
 import java.util.List;
 
 /**
@@ -19,7 +24,7 @@ public class InquiryUtils {
     /**
      * 访问地址
      */
-    private static String url = "http://localhost:8080/public/Inquiry";
+    private static String url = "http://localhost:8080";
 
     /**
      * 传递数据到公共询价接口方法
@@ -31,7 +36,7 @@ public class InquiryUtils {
      * @throws Exception
      */
     public static PublicInquiryItem save(PublicInquiryItem item) throws Exception {
-        String res = HttpUtil.doPost(url + "/item/add",  FlexJsonUtils.toJsonDeep(item));
+        String res = HttpUtil.doPost(url + "/inquiry/sale/item/save",  FlexJsonUtils.toJsonDeep(item));
         if (null != res) {
             Object obj = JSON.parse(res);
             return JSON.parseObject(obj.toString(), PublicInquiryItem.class);
@@ -49,7 +54,7 @@ public class InquiryUtils {
      * @throws Exception
      */
     public static PublicInquiry saveList(List<PublicInquiryItem> items) throws Exception {
-        String res = HttpUtil.doPost(url + "/items/save",  FlexJsonUtils.toJsonDeep(items));
+        String res = HttpUtil.doPost(url + "/inquiry/public/items/save",  FlexJsonUtils.toJsonDeep(items));
         if (null != res) {
             Object obj = JSON.parse(res);
             return JSON.parseObject(obj.toString(), PublicInquiry.class);
@@ -58,14 +63,14 @@ public class InquiryUtils {
     }
 
     /**
-     * 买家对供应商报价信息进行审核操作
+     * 卖家保存、更新报价信息
      *
      * @param inquiryItem 报价信息
      * @return
      * @throws Exception
      */
     public static PublicInquiryItem saveItem(PublicInquiryItem inquiryItem) throws Exception {
-        String res = HttpUtil.doPost(url + "/item/save",  FlexJsonUtils.toJsonDeep(inquiryItem));
+        String res = HttpUtil.doPost(url + "/inquiry/sale/item/save",  FlexJsonUtils.toJsonDeep(inquiryItem));
         if (null != res) {
             Object obj = JSON.parse(res);
             return JSON.parseObject(obj.toString(), PublicInquiryItem.class);
@@ -81,11 +86,122 @@ public class InquiryUtils {
      * @throws Exception
      */
     public static Attach addAttachs(Attach attach) throws Exception {
-        String res = HttpUtil.doPost(url + "/attach",  FlexJsonUtils.toJsonDeep(attach));
+        String res = HttpUtil.doPost(url + "/inquiry/sale/attach",  FlexJsonUtils.toJsonDeep(attach));
         if (null != res) {
             Object obj = JSON.parse(res);
             return JSON.parseObject(obj.toString(), Attach.class);
         }
         return null;
     }
+
+    /**
+     * 通过分页信息查询询价列表
+     *
+     * @param pageInfo 分页参数
+     * @param searchFilter 过滤条件
+     * @return
+     * @throws Exception
+     */
+    public static Page<PurcInquiryItemInfo> getInfo(PageInfo pageInfo, SearchFilter searchFilter) throws Exception {
+        JSONObject formData = JSON.parseObject(JSON.toJSONString(pageInfo));
+        if (searchFilter != null) {
+            formData.putAll(JSON.parseObject(JSON.toJSONString(searchFilter)));
+        }
+        HttpUtil.Response res = HttpUtil.sendGetRequest(url + "/inquiry/public", formData);
+        return (Page)JSONObject.parseObject(res.getResponseText(), new TypeReference<Page<PurcInquiryItemInfo>>() {
+        }, new Feature[0]);
+    }
+
+    /**
+     * 通过id查询公共询价详情
+     *
+     * @param id
+     * @param enuu
+     * @return
+     * @throws Exception
+     */
+    public static ModelMap findById(Long id, Long enuu) throws Exception {
+        JSONObject formData = new JSONObject();
+        formData.put("id", id);
+        formData.put("enuu", enuu);
+        HttpUtil.Response res = HttpUtil.sendGetRequest(url + "/inquiry/sale/publicInquiry/detail", formData);
+        ModelMap map = new ModelMap();
+        if (res.getStatusCode() == 200) {
+            JSONObject jsonObject = JSONObject.parseObject(res.getResponseText());
+            String itemStr = jsonObject.getString("inquiryItem");
+            if (null != itemStr) {
+                PurcInquiryItemInfo inquiryItem = JSONObject.parseObject(itemStr.toString(), PurcInquiryItemInfo.class);
+                map.put("inquiryItem", inquiryItem);
+            }
+            String idStr = jsonObject.getString("idid");
+            if (null != idStr) {
+                map.put("id", idStr);
+            }
+            return map;
+        } else {
+            throw new Exception("数据获取失败");
+        }
+    }
+
+    /**
+     * 买家对供应商报价信息的审核操作
+     *
+     * @param id 报价明细id
+     * @param status 状态
+     * @return
+     * @throws Exception
+     */
+    public static void decide(Long id, Short status) throws Exception {
+        JSONObject formData = JSON.parseObject(JSON.toJSONString(id));
+        formData.putAll(JSON.parseObject(JSON.toJSONString(status)));
+        HttpUtil.Response res = HttpUtil.sendPostRequest(url + "/inquiry/buyer/decide", formData);
+        if (res.getStatusCode() != 200) {
+            throw new Exception("审核失败");
+        }
+    }
+
+    /**
+     * 通过公共询价明细id和企业UU号查询是否已转报价
+     *
+     * @param id 公共询价明细id
+     * @param enuu 企业UU
+     * @return
+     * @throws Exception
+     */
+    public static PublicInquiryItem findBySourceId(Long id, Long enuu) throws Exception {
+        JSONObject formData = new JSONObject();
+        formData.put("id", id);
+        formData.put("enuu", enuu);
+        HttpUtil.Response res = HttpUtil.sendGetRequest(url + "/inquiry/sale/quote", formData);
+        if (res.getStatusCode() == 200) {
+            if (null != res.getResponseText()) {
+                return JSONObject.parseObject(res.getResponseText(), PublicInquiryItem.class);
+            }
+        } else {
+            throw new Exception("数据查询失败: " + res.getStatusCode());
+        }
+        return null;
+    }
+
+    /**
+     * 通过询价明细id查询报价详情
+     *
+     * @param id 公共询价明细id
+     * @param enuu 企业UU
+     * @return
+     * @throws Exception
+     */
+    public static PublicInquiryItem findInquiryById(Long id, Long enuu) throws Exception {
+        JSONObject formData = JSON.parseObject(JSON.toJSONString(id));
+        formData.putAll(JSON.parseObject(JSON.toJSONString(enuu)));
+        HttpUtil.Response res = HttpUtil.sendGetRequest(url + "/inquiry/sale/inquiry/detail", formData);
+        if (res.getStatusCode() == 200) {
+            if (null != res.getResponseText()) {
+                return JSONObject.parseObject(res.getResponseText(), PublicInquiryItem.class);
+            }
+        } else {
+            throw new Exception("数据查询失败: " + res.getStatusCode());
+        }
+        return null;
+    }
 }

+ 59 - 0
src/main/java/com/uas/platform/b2b/service/EnquiryService.java

@@ -0,0 +1,59 @@
+package com.uas.platform.b2b.service;
+
+import com.uas.platform.b2b.model.FileUpload;
+import com.uas.platform.b2b.model.PublicInquiryItem;
+import com.uas.platform.b2b.model.PurcInquiryItemInfo;
+import com.uas.platform.b2b.model.SearchFilter;
+import com.uas.platform.core.model.PageInfo;
+import com.uas.search.b2b.model.SPage;
+import org.springframework.ui.ModelMap;
+
+/**
+ * 公共询价操作接口
+ *
+ * Created by hejq on 2018-01-17.
+ */
+public interface EnquiryService {
+
+    /**
+     * 通过分页信息查询公共询价信息
+     *
+     * @param pageInfo 分页信息
+     * @param searchFilter 过滤条件
+     * @return
+     */
+    SPage<PurcInquiryItemInfo> fingByPageInfo(PageInfo pageInfo, SearchFilter searchFilter) throws Exception;
+
+    /**
+     * 通过id查询询价详情
+     *
+     * @param id 公共询价明细id
+     * @return
+     */
+    ModelMap getInquiryItemDetail(Long id) throws Exception;
+
+    /**
+     * 通过公共询价明细id查询报价信息
+     *
+     * @param id 公共询价明细id
+     * @return
+     */
+    ModelMap getQuotation(Long id) throws Exception;
+
+    /**
+     * 通过id查询报价详情
+     * @param id 报价明细id
+     * @return
+     */
+    ModelMap getInquiryDetail(Long id) throws Exception;
+
+    /**
+     * 将客户公共询价单转成询价报价单
+     *
+     * @param inquiryItem 报价详情
+     * @param method  方法
+     * @param uploadItem 附件
+     * @return
+     */
+    ModelMap turnToQuotation(PublicInquiryItem inquiryItem, String method, FileUpload uploadItem) throws Exception;
+}

+ 8 - 1
src/main/java/com/uas/platform/b2b/service/impl/DeputyOrderServiceImpl.java

@@ -342,7 +342,14 @@ public class DeputyOrderServiceImpl implements DeputyOrderService {
 	public List<DeputyOrder> findByDeputyuu(Long enuu) {
 		String entryStatus = "已提交";
 		String downloadStatus = "未下载";
-		return deputyOrderDao.getByDeputyuuAndEntrystatusAndDownloadstatus(enuu, entryStatus, downloadStatus);
+		List<Long> idList = new ArrayList<Long>();
+		idList.add(5351L);
+		idList.add(5349L);
+		idList.add(5347L);
+		idList.add(5346L);
+		idList.add(5343L);
+		return deputyOrderDao.findAll(idList);
+//		return deputyOrderDao.getByDeputyuuAndEntrystatusAndDownloadstatus(enuu, entryStatus, downloadStatus);
 	}
 
 	@Override

+ 126 - 0
src/main/java/com/uas/platform/b2b/service/impl/EnquiryServiceImpl.java

@@ -0,0 +1,126 @@
+ package com.uas.platform.b2b.service.impl;
+
+import com.uas.account.support.Page;
+import com.uas.platform.b2b.model.*;
+import com.uas.platform.b2b.ps.InquiryUtils;
+import com.uas.platform.b2b.service.AttachService;
+import com.uas.platform.b2b.service.EnquiryService;
+import com.uas.platform.b2b.support.SPageUtils;
+import com.uas.platform.b2b.support.SystemSession;
+import com.uas.platform.core.exception.IllegalOperatorException;
+import com.uas.platform.core.exception.NotFoundException;
+import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.Status;
+import com.uas.search.b2b.model.SPage;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.ui.ModelMap;
+
+import java.util.HashSet;
+import java.util.Set;
+
+ /**
+ * 公共询价操作方法实现
+ *
+ * Created by hejq on 2018-01-17.
+ */
+@Service
+public class EnquiryServiceImpl implements EnquiryService {
+
+    @Autowired
+    private AttachService attachService;
+
+    /**
+     * 通过分页信息查询公共询价信息
+     *
+     * @param pageInfo     分页信息
+     * @param searchFilter 过滤条件
+     * @return
+     */
+    @Override
+    public SPage<PurcInquiryItemInfo> fingByPageInfo(PageInfo pageInfo, SearchFilter searchFilter) throws Exception {
+        searchFilter.setEnUU(SystemSession.getUser().getEnterprise().getUu());
+        Page<PurcInquiryItemInfo> infos = InquiryUtils.getInfo(pageInfo, searchFilter);
+        return SPageUtils.covert(infos);
+    }
+
+     /**
+      * 通过id查询询价详情
+      *
+      * @param id
+      * @return
+      */
+     @Override
+     public ModelMap getInquiryItemDetail(Long id) throws Exception {
+         return InquiryUtils.findById(id, SystemSession.getUser().getEnterprise().getUu());
+     }
+
+     /**
+      * 通过id查询报价信息
+      *
+      * @param id 公共询价明细id
+      * @return
+      */
+     @Override
+     public ModelMap getQuotation(Long id) throws Exception {
+         ModelMap map = new ModelMap();
+         PublicInquiryItem inquiryItem = InquiryUtils.findBySourceId(id, SystemSession.getUser().getEnterprise().getUu());
+         if (null != inquiryItem) {
+             map.put("inquiryItem", inquiryItem);
+         }
+         return map;
+     }
+
+     /**
+      * 通过id查询报价详情
+      *
+      * @param id 报价明细id
+      * @return
+      */
+     @Override
+     public ModelMap getInquiryDetail(Long id) throws Exception {
+         ModelMap map = new ModelMap();
+         PublicInquiryItem inquiryItem = InquiryUtils.findInquiryById(id, SystemSession.getUser().getEnterprise().getUu());
+         if (null != inquiryItem) {
+             map.put("inquiryItem", inquiryItem);
+         } else {
+             throw new NotFoundException("未找到相关报价信息");
+         }
+         return map;
+     }
+
+     /**
+      * 将客户公共询价单转成询价报价单
+      *
+      * @param inquiryItem 报价详情
+      * @param method  方法
+      * @param uploadItem 附件
+      * @return
+      */
+     @Override
+     public ModelMap turnToQuotation(PublicInquiryItem inquiryItem, String method, FileUpload uploadItem) throws Exception {
+         inquiryItem.setQuDomain("B2B");
+         if (uploadItem.getFile() != null) {
+             Attach attach = attachService.upload(uploadItem, "PurchaseInquiryItemAttaches", "采购询价单报价附件");
+             Set<Attach> attachSet = inquiryItem.getAttaches() != null ? inquiryItem.getAttaches() : new HashSet<Attach>();
+             attachSet.add(attach);
+             inquiryItem.setAttaches(attachSet);
+         }
+         if ("reply".equals(method)) {
+             inquiryItem.setStatus((short) Status.REPLIED.value());
+             inquiryItem.setBackStatus((short) Status.NOT_UPLOAD.value());
+             inquiryItem.setReplySendStatus((short) Status.NOT_UPLOAD.value());
+             // 将采纳状态设置成申请状态,方便过滤
+             inquiryItem.setDecideStatus((short) Status.UNAUDIT.value());
+         }
+         inquiryItem.setVendUU(SystemSession.getUser().getEnterprise().getUu());
+         inquiryItem.setVendUserUU(SystemSession.getUser().getUserUU());
+         inquiryItem = InquiryUtils.save(inquiryItem);
+         // 这边的id可能是询价的id,但是不会赋值sourceID,所以如果sourceID有值,应该是已经保存过了
+         if (null != inquiryItem.getSourceId()) {
+            return new ModelMap("success", "报价成功");
+         } else {
+             throw new IllegalOperatorException("报价失败");
+         }
+     }
+ }

+ 103 - 22
src/main/webapp/resources/js/index/app.js

@@ -5228,7 +5228,7 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
     }]);
 
     // 公共询价列表
-    app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', 'publicInquiry', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry, publicInquiry) {
+    app.controller('PublicInquiryListCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'PurcInquiry', 'publicInquiry', 'publicInquiryList', '$modal', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, PurcInquiry, publicInquiry, publicInquiryList, $modal) {
         BaseService.scrollBackToTop();
         /**
          * 改变单据日期范围
@@ -5333,11 +5333,12 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         };
 
         var getService = function () {
-            if ($scope.active == 'teams') {
-                return PurchaseInquiry.hisquotation;
-            } else {
-                return PurchaseInquiry.publicInquiryItem;
-            }
+            // if ($scope.active == 'teams') {
+            //     return PurchaseInquiry.hisquotation;
+            // } else {
+            //     return PurchaseInquiry.publicInquiryItem;
+            // }
+            return publicInquiryList.getInquirylist;
         }
 
         $scope.tableParams = new ngTableParams({
@@ -5394,38 +5395,118 @@ define(['toaster', 'charts', 'ngTable', 'common/services', 'common/directives',
         });
 
         // 转客户询价
-        $scope.transtoInquiry = function (id) {
-            publicInquiry.turnToInquiry({id: id}, {}, function (data) {
-                if (data.success) {
-                    toaster.pop('success', '提示', data.success);
-                    window.location.hash = "sale/pubinquiry/" + data.id;
-                }
-                if (data.error) {
-                    toaster.pop('error', '提示', data.error);
-                }
-                if (data.info) {
-                    toaster.pop('info', '提示', data.info);
-                    window.open("#/sale/pubinquiry/" + data.inid);
+        $scope.transtoInquiry = function (inquiryItem) {
+            publicInquiry.quotationInfo({id: inquiryItem.id}, function(data) {
+                console.log(data);
+                if (data.inquiryItem) { //存在已报价的就不进行报价操作
+                    toaster.pop('error', '该询价单已已经报价');
+                } 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.item.product = data;
+                    }, function () {
+
+                    });
                 }
-            }, function (response) {
-                toaster.pop('error', '提示', response.data);
             });
+
         }
 
         // 跳转到我的报价列表
         $scope.linkToInquiry = function () {
             window.open("#/sale/pubinquiry");
         }
+
+    }]);
+
+    /**
+     * 报价操作
+     */
+    app.controller('QuoteCtrl', ['$scope', 'inquiryItem', 'toaster', 'publicInquiry', '$modalInstance', '$upload', function($scope, inquiryItem, toaster, publicInquiry, $modalInstance, $upload) {
+        $scope.inquiryItem = inquiryItem;
+        if ($scope.inquiryItem.replies == null) {
+            $scope.inquiryItem.replies = [];
+            var reply = {
+                lapQty: null,
+                price: null
+            };
+            $scope.inquiryItem.replies.push(reply);
+        }
+        $scope.replyPrices = [];
+        $scope.replylapQtys = [];
+        $scope.replyPrices.push(true);
+        $scope.replylapQtys.push(true);
+
+        // 增加一列分段报价
+        $scope.addStep = function (inquiryItem) {
+            $scope.replyPrices.push(true);
+            if (inquiryItem.replies.length >= 5) {
+                toaster.pop('warning', '提示', '最多支持5个分段!');
+            } 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.cancel = function() {
+            $modalInstance.dismiss();
+        }
+
+        // 保存报价信息
+        $scope.save = function(inquiryItem) {
+            var file = $scope.myFiles, file = file && file.length > 0 ? file[0] : null;// 可以不传附件
+            $upload.upload({
+                url: 'pubInquiry/turnToQuotation',
+                file: file,
+                method: 'POST',
+                data: {
+                    item: inquiryItem,
+                    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', '附件上传失败');
+            });
+        }
     }]);
 
+
     /**
      * 公共询价详情
      */
-    app.controller('PublicInquiryListDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'AccountEnterprise', 'publicInquiry', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, AccountEnterprise, publicInquiry) {
+    app.controller('PublicInquiryListDetailCtrl', ['$scope', '$stateParams', 'PurchaseInquiry', '$filter', 'toaster', 'BaseService', 'ngTableParams', 'AccountEnterprise', 'publicInquiry', 'publicInquiryList', function ($scope, $stateParams, PurchaseInquiry, $filter, toaster, BaseService, ngTableParams, AccountEnterprise, publicInquiry, publicInquiryList) {
         BaseService.scrollBackToTop();
         $scope.currentHasBid = false;
         var loadData = function () {
-            PurchaseInquiry.inquiryItemDetail({id: $stateParams.id}, function (data) {
+            publicInquiryList.getDetail({id: $stateParams.id}, function (data) {
                 $scope.inquiryItem = data.inquiryItem;
                 if (data.id) {
                     $scope.id = data.id;

+ 35 - 0
src/main/webapp/resources/js/index/services/PublicInquiry.js

@@ -71,6 +71,20 @@ define([ 'ngResource'], function() {
             refuse: {
                 url: 'purc/pubInquiry/refuse/:id',
                 method: 'POST'
+            },
+            /**
+             * 将公共询价转询价报价
+             */
+            turnToQuotation: {
+                url: 'pubInquiry/turnToQuotation',
+                method: 'POST'
+            },
+            /**
+             * 根据公共询价明细id,用id查询该条数据是否已报价
+             */
+            quotationInfo: {
+                url: 'pubInquiry/quotation/:id',
+                method: 'GET'
             }
         })
     }]).factory('PubInquiryNoSearchInfo', ['$resource', function($resource) {
@@ -317,5 +331,26 @@ define([ 'ngResource'], function() {
                 }
             }
         });
+    }]).factory('publicInquiryList', ['$resource', function($resource) {
+        /**
+         * 首页公共询价更多里面展示的所有企业发布的公共询价信息列表
+         *     这里只做信息获取,不加其他方法
+         */
+        return $resource('pubInquiry', {}, {
+            /**
+             * 得到所有的单据
+             */
+            getInquirylist: {
+                url: 'pubInquiry/list',
+                method: 'GET'
+            },
+            /**
+             * 通过id查询公共询价详情
+             */
+            getDetail: {
+                url: 'pubInquiry/:id',
+                method: 'GET'
+            }
+        });
     }])
 });

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

@@ -397,7 +397,7 @@
                                         <td ng-click="toDetail(inquiryItem.id)" title="查看详情" ng-bind="inquiryItem.needquantity"></td>
                                         <td ng-click="toDetail(inquiryItem.id)" title="查看详情" ng-bind="inquiryItem.inquiry.enterprise.enName"><a></a></td>
                                         <td ng-click="toDetail(inquiryItem.id)" title="查看详情" ng-bind="inquiryItem.inquiry.endDate| date: 'yyyy-MM-dd'"></td>
-                                        <td><a class="offer" ng-click="transtoInquiry(inquiryItem.id)">我要报价</a></td>
+                                        <td><a class="offer" ng-click="transtoInquiry(inquiryItem)">我要报价</a></td>
                                     </tr>
                                </tbody>
                                <tbody ng-if="active == 'teams'">

+ 236 - 0
src/main/webapp/resources/tpl/index/baseInfo/modal/quotation_modal.html

@@ -0,0 +1,236 @@
+<style>
+    .modal-dialog{
+        position: fixed;
+        top: 23%;
+        left: 50%;
+        margin: -150px 0 0 -195px;
+    }
+    .modal-content{
+        width: 700px;
+        min-height: 420px;
+    }
+    .modal-header {
+        width: 100%;
+        height: 39px;
+        text-align: left;
+        background: #fff;
+        border-top-left-radius: 6px;
+        border-top-right-radius: 6px;
+    }
+    .modal-header span{
+        padding-left: 18px;
+        font-size: 14px;
+        color: #323232;
+        font-weight: bold;
+    }
+    .modal-body{
+        padding:30px 25px 10px 25px;
+        margin-left: 15px;
+    }
+    .modal-add{
+        background: #f5f5f5;
+        margin-left: 0;
+        padding: 20px 20px 20px 40px;
+    }
+    .modal-add i{
+        position: absolute;
+        top: 4px;
+        right: 0;
+        display: block;
+        width: 30px;
+        text-align: center;
+        height: 30px;
+        line-height: 30px;
+        font-size: 20px;
+    }
+    .modal-body .modal-file{
+        margin-left:-15px;
+    }
+    .modal-body .modal-file span{
+        font-size: 14px;
+        color:#999;
+    }
+    .modal-body .modal-file a{
+        color:#5078Cb;
+    }
+    .modal-body .modal-file a:hover{
+        cursor:pointer;
+        text-decoration: underline;
+    }
+    .modal-body .form-horizontal{
+        padding-left:0;
+    }
+    .modal-body .form-group{
+        margin:0 0 15px 0;
+    }
+    .modal-body .control-label{
+        text-align:left;
+        padding:0;
+        padding-top:7px;
+    }
+    .modal-body .bottom{
+        padding-top:10px;
+    }
+    .modal-body .bottom a{
+        display:inline-block;
+        color:#5078Cb;
+        font-size: 14px;
+        margin-bottom:15px;
+        text-decoration: none;
+    }
+    .modal-body .bottom a:hover{
+        cursor:pointer;
+        text-decoration: underline;
+    }
+    .modal-body .bottom a i{
+        margin-right:10px;
+    }
+    .modal-footer{
+        border-top: none;
+    }
+    .modal-footer button{
+        display: inline-block;
+        width: 80px;
+        height: 32px;
+        font-size: 14px;
+        background: #fff;
+        color:#5078Cb;
+        text-align: center;
+        text-decoration: none;
+        border-radius: 4px;
+        border:1px solid #5078Cb;
+        outline: none;
+        margin-right: 10px;
+    }
+    .modal-footer button:last-child{
+        background: #fff;
+        border:1px solid #d2d2d2;
+        color:#666;
+    }
+    .modal-footer button:hover{
+        background: #3578ba;
+        color:#fff;
+        border:1px solid #5078Cb;
+    }
+    .modal-footer span{
+        color:#999;
+        margin-right:10px;
+    }
+</style>
+<div class="modal-header">
+    <span>报价详情</span>
+</div>
+<div class="modal-body">
+    <div class="row">
+        <div class="col-xs-6 form-horizontal">
+            <div class="form-group">
+                <label for="inputEmail3" class="col-xs-4 control-label">最小订购</label>
+                <div class="col-xs-8">
+                    <input type="text" class="form-control" id="inputEmail3" placeholder="1000" ng-model="inquiryItem.minOrderQty">
+                </div>
+            </div>
+        </div>
+        <div class="col-xs-6 form-horizontal">
+            <div class="form-group">
+                <label for="inputEmail1" class="col-xs-4 control-label">最小包装</label>
+                <div class="col-xs-8">
+                    <input type="text" class="form-control" id="inputEmail1" placeholder="1000" ng-model="inquiryItem.minPackQty">
+                </div>
+            </div>
+        </div>
+        <div class="col-xs-6 form-horizontal">
+            <div class="form-group">
+                <label for="inputEmail2" class="col-xs-4 control-label">交货周期(天)</label>
+                <div class="col-xs-8">
+                    <input type="text" class="form-control" id="inputEmail2" placeholder="20" ng-model="inquiryItem.leadtime">
+                </div>
+            </div>
+        </div>
+        <div class="col-xs-6 form-horizontal">
+            <div class="form-group">
+                <label class="col-xs-4 control-label">币种(选择)</label>
+                <div class="col-xs-8">
+                    <select name="" id="" class="form-control" inquiryItem="inquiryItem.currency">
+                        <option value="RMB">RMB</option>
+                        <option value="YEN">YEN</option>
+                    </select>
+                </div>
+            </div>
+        </div>
+        <div class="col-xs-6 form-horizontal">
+            <div class="form-group">
+                <label for="inputEmail4" class="col-xs-4 control-label">税率(%)</label>
+                <div class="col-xs-8">
+                    <input type="text" class="form-control" id="inputEmail4" placeholder="10" ng-model="inquiryItem.taxrate">
+                </div>
+            </div>
+        </div>
+        <div class="col-xs-6 form-horizontal">
+            <div class="form-group">
+                <label for="inputEmail5" class="col-xs-4 control-label">供应商型号</label>
+                <div class="col-xs-8">
+                    <input type="text" class="form-control" id="inputEmail5" placeholder="1000">
+                </div>
+            </div>
+        </div>
+        <div ng-repeat="reply in inquiryItem.replies">
+            <div class="col-xs-6 form-horizontal">
+                <div class="form-group">
+                    <label for="inputEmail6" class="col-xs-4 control-label">分段数量<span ng-bind="$index + 1" ng-if="inquiryItem.replies.length > 1"></span></label>
+                    <div class="col-xs-8">
+                        <input type="text" class="form-control" id="inputEmail6" ng-model="reply.lapQty">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-6 form-horizontal">
+                <div class="form-group">
+                    <label for="inputEmail7" class="col-xs-4 control-label">价格<span ng-bind="$index + 1" ng-if="inquiryItem.replies.length > 1"></span></label>
+                    <div class="col-xs-8">
+                        <input type="text" class="form-control" id="inputEmail7" ng-model="reply.price">
+                    </div>
+                </div>
+            </div>
+            <a ng-click="removeStep(inquiryItem, $index)" ng-if="!$first"><i class="fa fa-trash"></i></a>
+        </div>
+</div>
+<div class="modal-body modal-add">
+    <div class="row" >
+        <div style="position:relative;" ng-repeat="">
+            <i class="fa fa-trash"></i>
+            <div class="col-xs-6 form-horizontal">
+                <div class="form-group">
+                    <label for="inputNum1" class="col-xs-4 control-label">分段数量</label>
+                    <div class="col-xs-8">
+                        <input type="text" class="form-control" id="inputNum1">
+                    </div>
+                </div>
+            </div>
+            <div class="col-xs-6 form-horizontal">
+                <div class="form-group">
+                    <label for="inputNum2" class="col-xs-4 control-label">价格</label>
+                    <div class="col-xs-8">
+                        <input type="text" class="form-control" id="inputNum2">
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+    <div class="modal-file">
+        <span>附件:</span><a href="javascript:void(0)">1651656.pdf</a>
+    </div>
+</div>
+<div class="modal-body">
+    <div class="bottom">
+        <a ng-click="addStep(inquiryItem)"><i class="fa fa-plus"></i>增加分段数量和分段报价</a>
+        <br/>
+        <a href=""><i class="fa fa-plus"></i>添加附件</a>
+        <input type="file" ng-file-select name="file" ng-model="myFiles">
+    </div>
+</div>
+<div class="modal-footer">
+    <span>确认报价后,将无法修改</span>
+    <button ng-click="submit(inquiryItem)">确认报价</button>
+    <button ng-click="save(inquiryItem)">保存</button>
+    <button ng-click="cancel()">取消</button>
+</div>
+</div>