Browse Source

盘点单

zhoudw 7 years ago
parent
commit
0309cc501f
16 changed files with 338 additions and 168 deletions
  1. 0 1
      applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java
  2. 1 1
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/dto/ProdIODetailDTO.java
  3. 1 1
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/Make.java
  4. 3 121
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/MakeMaterial.java
  5. 2 2
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdIODetail.java
  6. 2 2
      applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/StockTaking.java
  7. 28 2
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/controller/StocktakingController.java
  8. 1 1
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/mapper/MakeMapper.java
  9. 7 1
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/mapper/StockTakingMapper.java
  10. 5 0
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/StocktakingService.java
  11. 156 2
      applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/StocktakingServiceImpl.java
  12. 18 1
      applications/storage/storage-server/src/main/resources/mapper/StockTakingMapper.xml
  13. 107 31
      frontend/saas-web/app/view/stock/inventory/EditDataList.js
  14. 5 0
      frontend/saas-web/app/view/stock/inventory/EditDataListModel.js
  15. 1 1
      frontend/saas-web/app/view/stock/otherIn/FormPanel.js
  16. 1 1
      frontend/saas-web/app/view/stock/otherOut/FormPanel.js

+ 0 - 1
applications/purchase/purchase-server/src/main/java/com/usoftchina/saas/purchase/service/impl/ProdInOutServiceImpl.java

@@ -438,7 +438,6 @@ public class ProdInOutServiceImpl extends CommonBaseServiceImpl<ProdInOutMapper,
         targetPi.setPi_date(new Date());
         targetPi.setPi_status("未审核");
         targetPi.setPi_statuscode("UNAUDITED");
-        targetPi.setPi_recorddate(new Date());
         targetPi.setPi_vendid(sourcePi.getPi_vendid());
         targetPi.setPi_vendcode(sourcePi.getPi_vendcode());
         targetPi.setPi_vendname(sourcePi.getPi_vendname());

+ 1 - 1
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/dto/ProdIODetailDTO.java

@@ -49,7 +49,7 @@ public class ProdIODetailDTO extends CommonBaseDTO implements Serializable {
 
     private Double pd_nettotal;
 
-    private Integer pd_whid;
+    private Long pd_whid;
 
     private String pd_whcode;
 

+ 1 - 1
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/Make.java

@@ -30,7 +30,7 @@ public class Make extends CommonBaseEntity implements Serializable {
 
     private Double ma_qty;
 
-    private Integer ma_whid;
+    private Long ma_whid;
 
     private String ma_whcode;
 

+ 3 - 121
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/MakeMaterial.java

@@ -2,16 +2,16 @@ package com.usoftchina.saas.storage.po;
 
 import com.usoftchina.saas.base.entity.CommonBaseEntity;
 import com.usoftchina.saas.document.dto.ProductDTO;
-import com.usoftchina.saas.document.entities.Product;
+import lombok.Data;
 
 import java.io.Serializable;
-import java.util.Date;
 
 /**
  * 制造单明细
  * @author chenwei
  * @date 2018/10/29
  */
+@Data
 public class MakeMaterial extends CommonBaseEntity implements Serializable {
     private Long mm_maid;
 
@@ -21,7 +21,7 @@ public class MakeMaterial extends CommonBaseEntity implements Serializable {
 
     private String mm_prodcode;
 
-    private Integer mm_whid;
+    private Long mm_whid;
 
     private String mm_whcode;
 
@@ -41,123 +41,5 @@ public class MakeMaterial extends CommonBaseEntity implements Serializable {
 
     private ProductDTO productDTO;
 
-    public String getMm_whname() {
-        return mm_whname;
-    }
 
-    public void setMm_whname(String mm_whname) {
-        this.mm_whname = mm_whname;
-    }
-
-    public ProductDTO getProductDTO() {
-        return productDTO;
-    }
-
-    public void setProductDTO(ProductDTO productDTO) {
-        this.productDTO = productDTO;
-    }
-
-    public Long getMm_maid() {
-        return mm_maid;
-    }
-
-    public void setMm_maid(Long mm_maid) {
-        this.mm_maid = mm_maid;
-    }
-
-    public Integer getMm_detno() {
-        return mm_detno;
-    }
-
-    public void setMm_detno(Integer mm_detno) {
-        this.mm_detno = mm_detno;
-    }
-
-    public Long getMm_prodid() {
-        return mm_prodid;
-    }
-
-    public void setMm_prodid(Long mm_prodid) {
-        this.mm_prodid = mm_prodid;
-    }
-
-    public String getMm_prodcode() {
-        return mm_prodcode;
-    }
-
-    public void setMm_prodcode(String mm_prodcode) {
-        this.mm_prodcode = mm_prodcode == null ? null : mm_prodcode.trim();
-    }
-
-    public Integer getMm_whid() {
-        return mm_whid;
-    }
-
-    public void setMm_whid(Integer mm_whid) {
-        this.mm_whid = mm_whid;
-    }
-
-    public String getMm_whcode() {
-        return mm_whcode;
-    }
-
-    public void setMm_whcode(String mm_whcode) {
-        this.mm_whcode = mm_whcode == null ? null : mm_whcode.trim();
-    }
-
-    public Double getMm_price() {
-        return mm_price;
-    }
-
-    public void setMm_price(Double mm_price) {
-        this.mm_price = mm_price;
-    }
-
-    public Double getMm_oneuseqty() {
-        return mm_oneuseqty;
-    }
-
-    public void setMm_oneuseqty(Double mm_oneuseqty) {
-        this.mm_oneuseqty = mm_oneuseqty;
-    }
-
-    public Double getMm_qty() {
-        return mm_qty;
-    }
-
-    public void setMm_qty(Double mm_qty) {
-        this.mm_qty = mm_qty;
-    }
-
-    public Double getMm_amount() {
-        return mm_amount;
-    }
-
-    public void setMm_amount(Double mm_amount) {
-        this.mm_amount = mm_amount;
-    }
-
-    public String getMm_repprodcode() {
-        return mm_repprodcode;
-    }
-
-    public void setMm_repprodcode(String mm_repprodcode) {
-        this.mm_repprodcode = mm_repprodcode == null ? null : mm_repprodcode.trim();
-    }
-
-    public String getMm_remark() {
-        return mm_remark;
-    }
-
-    public void setMm_remark(String mm_remark) {
-        this.mm_remark = mm_remark == null ? null : mm_remark.trim();
-    }
-
-    public Date getUpdateTime() {
-        return updateTime;
-    }
-
-    public void setUpdateTime(Date updateTime) {
-        this.updateTime = updateTime;
-    }
 }

+ 2 - 2
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/ProdIODetail.java

@@ -45,13 +45,13 @@ public class ProdIODetail extends CommonBaseEntity implements Serializable {
 
     private Double pd_nettotal;
 
-    private Integer pd_whid;
+    private Long pd_whid;
 
     private String pd_whcode;
 
     private String pd_whname;
 
-    private Integer pd_inwhid;
+    private Long pd_inwhid;
 
     private String pd_inwhcode;
 

+ 2 - 2
applications/storage/storage-dto/src/main/java/com/usoftchina/saas/storage/po/StockTaking.java

@@ -7,7 +7,7 @@ import java.io.Serializable;
 @Data
 public class StockTaking extends CommonBaseEntity implements Serializable {
 
-    private Integer st_prodid;
+    private Long st_prodid;
 
     private String st_prodcode;
 
@@ -19,7 +19,7 @@ public class StockTaking extends CommonBaseEntity implements Serializable {
 
     private String st_produnit;
 
-    private Integer st_whid;
+    private Long st_whid;
 
     private String st_whcode;
 

+ 28 - 2
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/controller/StocktakingController.java

@@ -12,6 +12,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
+import java.util.Map;
 
 @RestController
 @RequestMapping("/stocktaking")
@@ -22,6 +23,17 @@ public class StocktakingController {
     @Autowired
     private StocktakingService stocktakingService;
 
+    /**
+     * 生成临时表数据
+     * @param page
+     * @param listReqDTO
+     * @return
+     */
+    @PostMapping("/build")
+    public Result buildListDataByCondition(@RequestBody ListReqDTO listReqDTO){
+        stocktakingService.buildListDataByCondition(listReqDTO);
+        return Result.success();
+    }
 
 
     /**
@@ -35,8 +47,11 @@ public class StocktakingController {
         return Result.success(stocktakingService.getList(page, listReqDTO));
     }
 
-
-
+    /**
+     * 保存
+     * @param list
+     * @return
+     */
     @PostMapping("/save")
     public Result save(@RequestBody List<StockTakingDTO> list){
         DocBaseDTO docBaseDTO = stocktakingService.saveOrUpdate(list);
@@ -44,6 +59,17 @@ public class StocktakingController {
     }
 
 
+    /**
+     * 生成盘点单据
+     * @param list
+     * @return
+     */
+    @GetMapping("/stock")
+    public Result stock(){
+        Map<String,Object> map = stocktakingService.stock();
+        return Result.success(map);
+    }
+
 
 
 }

+ 1 - 1
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/mapper/MakeMapper.java

@@ -26,7 +26,7 @@ public interface MakeMapper extends CommonBaseMapper<Make> {
 
     int validateCodeWhenUpdate(@Param("code") String code, @Param("id") Long id, @Param("companyId") Long company);
 
-    Double getOnHand(@Param("prodid") Long prodid, @Param("whid") Integer whid, @Param("companyId") Long companyId);
+    Double getOnHand(@Param("prodid") Long prodid, @Param("whid") Long whid, @Param("companyId") Long companyId);
 
     ProdInOut selectMakeInOutCode(@Param("code") String code, @Param("companyId") Long companyId, @Param("type") String type);
 

+ 7 - 1
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/mapper/StockTakingMapper.java

@@ -15,5 +15,11 @@ public interface StockTakingMapper extends CommonBaseMapper<StockTaking> {
 
     int updateByPrimaryKeySelective(StockTaking record);
 
-    List<StockTaking> selectStockTakingBycondition(@Param("con") String con, @Param("companyId") Long companyId);
+    List<StockTaking> selectStockTakingBycondition(@Param("con") String con,@Param("companyId") Long companyId);
+
+    void deleteByCompany(@Param("companyId") Long companyId);
+
+    void insertFormProductWh(@Param("con") String con,@Param("companyId") Long companyId);
+
+    Double getPurcpriceByProduct(Long id);
 }

+ 5 - 0
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/StocktakingService.java

@@ -11,10 +11,15 @@ import com.usoftchina.saas.storage.mapper.StockTakingMapper;
 import com.usoftchina.saas.storage.po.StockTaking;
 
 import java.util.List;
+import java.util.Map;
 
 public interface StocktakingService extends CommonBaseService<StockTakingMapper, StockTaking> {
 
     PageInfo<StockTaking>  getList(PageRequest page, ListReqDTO listReqDTO);
 
     DocBaseDTO saveOrUpdate(List<StockTakingDTO> list);
+
+    void buildListDataByCondition(ListReqDTO listReqDTO);
+
+    Map<String,Object> stock();
 }

+ 156 - 2
applications/storage/storage-server/src/main/java/com/usoftchina/saas/storage/service/impl/StocktakingServiceImpl.java

@@ -3,19 +3,31 @@ package com.usoftchina.saas.storage.service.impl;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.usoftchina.saas.base.service.CommonBaseServiceImpl;
+import com.usoftchina.saas.commons.api.MaxnumberService;
 import com.usoftchina.saas.commons.dto.DocBaseDTO;
 import com.usoftchina.saas.commons.dto.ListReqDTO;
+import com.usoftchina.saas.commons.exception.BizExceptionCode;
+import com.usoftchina.saas.commons.po.BillCodeSeq;
 import com.usoftchina.saas.context.BaseContextHolder;
+import com.usoftchina.saas.exception.BizException;
 import com.usoftchina.saas.page.PageRequest;
 import com.usoftchina.saas.storage.dto.StockTakingDTO;
+import com.usoftchina.saas.storage.mapper.ProdIODetailMapper;
+import com.usoftchina.saas.storage.mapper.ProdInOutMapper;
 import com.usoftchina.saas.storage.mapper.StockTakingMapper;
+import com.usoftchina.saas.storage.po.ProdIODetail;
+import com.usoftchina.saas.storage.po.ProdInOut;
 import com.usoftchina.saas.storage.po.StockTaking;
 import com.usoftchina.saas.storage.service.StocktakingService;
 import com.usoftchina.saas.utils.BeanMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Created by zdw
@@ -24,6 +36,15 @@ import java.util.List;
 @Service
 public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMapper, StockTaking> implements StocktakingService {
 
+    @Autowired
+    private MaxnumberService maxnumberService;
+    @Autowired
+    private ProdInOutMapper prodInOutMapper;
+    @Autowired
+    private ProdIODetailMapper prodIODetailMapper;
+
+
+
     @Override
     public PageInfo<StockTaking> getList(PageRequest page, ListReqDTO listReqDTO) {
         PageHelper.startPage(page.getNumber(), page.getSize());
@@ -44,14 +65,147 @@ public class StocktakingServiceImpl extends CommonBaseServiceImpl<StockTakingMap
         return baseDTO;
     }
 
-    private List<StockTaking> getList(ListReqDTO listReqDTO) {
+    @Override
+    @Transactional
+    public void buildListDataByCondition(ListReqDTO listReqDTO) {
         List<StockTaking> list = null;
         Long companyId = BaseContextHolder.getCompanyId();
         String con = listReqDTO.getFinalCondition();
+        //删除该companyid的数据
+        getMapper().deleteByCompany(companyId);
         if (null == con) {
             con = "1=1";
         }
-        list = getMapper().selectStockTakingBycondition(con,companyId);
+        //查询存入临时表
+        getMapper().insertFormProductWh(con,companyId);
+    }
+
+    @Override
+    @Transactional
+    public Map<String,Object> stock() {
+        Map<String,Object> resultMap = new HashMap();
+
+        Long companyId = BaseContextHolder.getCompanyId();
+        Long userId = BaseContextHolder.getUserId();
+        //生成入库单
+        ProdInOut prodIn = new ProdInOut();
+        String piInno = getMaxnumber(BillCodeSeq.OTHERIN);
+        prodIn.setPi_inoutno(piInno);
+        prodIn.setPi_class(BillCodeSeq.OTHERIN.getName());
+        prodIn.setPi_date(new Date());
+        prodIn.setPi_status("未审核");
+        prodIn.setPi_statuscode("UNAUDITED");
+        prodIn.setCompanyId(companyId);
+        prodIn.setCreateTime(new Date());
+        prodIn.setCreatorId(userId);
+        prodIn.setPi_remark("盘盈单");
+        prodInOutMapper.insertSelective(prodIn);
+        long inid = prodIn.getId();
+
+        Double purcprice = null;
+
+        List<StockTaking> inlist  = getMapper().selectStockTakingBycondition("st_num>0",companyId);
+        for (int i=0;i<inlist.size();i++) {
+            StockTaking st = inlist.get(i);
+            ProdIODetail prodInDetail = new ProdIODetail();
+            prodInDetail.setPd_piid(inid);
+            prodInDetail.setPd_inoutno(piInno);
+            prodInDetail.setPd_piclass(BillCodeSeq.OTHERIN.getName());
+            prodInDetail.setPd_pdno(i+1);
+
+            purcprice = getMapper().getPurcpriceByProduct(st.getSt_prodid());
+            prodInDetail.setPd_orderprice(purcprice==null?0:purcprice);
+            prodInDetail.setPd_prodid(st.getSt_prodid());
+            prodInDetail.setPd_prodcode(st.getSt_prodcode());
+            prodInDetail.setPd_inqty(st.getSt_num());
+            //仓库
+            prodInDetail.setPd_whid(st.getSt_whid());
+            prodInDetail.setPd_whcode(st.getSt_whcode());
+            prodInDetail.setPd_whname(st.getSt_whname());
+            prodInDetail.setCompanyId(companyId);
+            prodInDetail.setCreateTime(new Date());
+            prodInDetail.setCreatorId(userId);
+            prodIODetailMapper.insertSelective(prodInDetail);
+        }
+
+        //生成出库单
+        ProdInOut prodOut = new ProdInOut();
+        String piOutno = getMaxnumber(BillCodeSeq.OTHEROUT);
+        prodOut.setPi_inoutno(piOutno);
+        prodOut.setPi_class(BillCodeSeq.OTHEROUT.getName());
+        prodOut.setPi_date(new Date());
+        prodOut.setPi_status("未审核");
+        prodOut.setPi_statuscode("UNAUDITED");
+        prodOut.setCompanyId(companyId);
+        prodOut.setCreateTime(new Date());
+        prodOut.setCreatorId(userId);
+        prodOut.setPi_remark("盘亏单");
+        prodInOutMapper.insertSelective(prodOut);
+        long outid = prodOut.getId();
+
+        List<StockTaking> outlist  = getMapper().selectStockTakingBycondition("st_num<0",companyId);
+        for (int i=0;i<outlist.size();i++) {
+            StockTaking st = outlist.get(i);
+            ProdIODetail prodOutDetail = new ProdIODetail();
+            prodOutDetail.setPd_piid(outid);
+            prodOutDetail.setPd_inoutno(piOutno);
+            prodOutDetail.setPd_piclass(BillCodeSeq.OTHERIN.getName());
+            prodOutDetail.setPd_pdno(i+1);
+            prodOutDetail.setPd_prodid(st.getSt_prodid());
+            prodOutDetail.setPd_prodcode(st.getSt_prodcode());
+            prodOutDetail.setPd_outqty(-st.getSt_num());
+            //仓库
+            prodOutDetail.setPd_whid(st.getSt_whid());
+            prodOutDetail.setPd_whcode(st.getSt_whcode());
+            prodOutDetail.setPd_whname(st.getSt_whname());
+            prodOutDetail.setCompanyId(companyId);
+            prodOutDetail.setCreateTime(new Date());
+            prodOutDetail.setCreatorId(userId);
+            prodIODetailMapper.insertSelective(prodOutDetail);
+        }
+        DocBaseDTO baseDTOIN = new DocBaseDTO(inid,piInno,"其它入库单");
+        DocBaseDTO baseDTOOUT = new DocBaseDTO(outid,piOutno,"其它出库单");
+        resultMap.put("inData",baseDTOIN);
+        resultMap.put("outData",baseDTOOUT);
+        return resultMap;
+    }
+
+    private List<StockTaking> getList(ListReqDTO listReqDTO) {
+        List<StockTaking> list = null;
+        Long companyId = BaseContextHolder.getCompanyId();
+        list = getMapper().selectStockTakingBycondition(null,companyId);
         return list;
     }
+
+
+    public String getMaxnumber(BillCodeSeq bill) {
+        String code = maxnumberService.getMaxnumber(bill.getCaller(), false).getData();
+        DocBaseDTO base = new DocBaseDTO(0l, code, bill.getName());
+        return pushMaxnubmer(base);
+    }
+
+    public String pushMaxnubmer(DocBaseDTO baseDTO) {
+        String pi_inoutno = baseDTO.getCode();
+        String pi_class = baseDTO.getName();
+        Long id = baseDTO.getId();
+        if (null == pi_inoutno) {
+            throw new BizException(BizExceptionCode.NULL_CODE);
+        }
+        Long companyId = BaseContextHolder.getCompanyId();
+        String billCode = null;
+        synchronized (ProdInOutServiceImpl.class) {
+            Integer count = "0".equals(String.valueOf(id)) ? prodInOutMapper.validateCodeWhenInsert(pi_inoutno, companyId) :
+                    prodInOutMapper.validateCodeWhenUpdate(pi_inoutno, id, companyId);
+            String caller ="";
+            if("其它入库单".equals(pi_class)){
+                caller = BillCodeSeq.OTHERIN.getCaller();
+            }else if("其它出库单".equals(pi_class)) {
+                caller = BillCodeSeq.OTHEROUT.getCaller();
+            }
+            billCode = maxnumberService.pushMaxnubmer(count, pi_inoutno, caller).getData();
+        }
+        return billCode;
+    }
+
+
 }

+ 18 - 1
applications/storage/storage-server/src/main/resources/mapper/StockTakingMapper.xml

@@ -238,11 +238,28 @@
         ${con}
       </if>
       <if test="companyId != null">
-        and  companyId = #{companyId}
+      and companyId = #{companyId}
       </if>
+
     </where>
     order by st_id desc
   </select>
 
+  <delete id="deleteByCompany" parameterType="long">
+    delete from stocktaking
+    where companyId = #{companyId,jdbcType=INTEGER}
+  </delete>
+
+  <insert id="insertFormProductWh">
+    insert into stocktaking (st_prodid,st_prodcode,st_proddetail,st_prodorispeccode,st_prodkind,st_produnit,st_whid,st_whcode,st_whname,st_batchqty,companyId)
+    select pr_id,pr_code,pr_detail,pr_orispeccode,pr_kind,pr_unit,wh_id,wh_code,wh_description,pw_onhand,#{companyId} from productwh left join product on pw_prodid = pr_id  left join warehouse on pw_whid = wh_id
+    where productwh.companyid=#{companyId,jdbcType=INTEGER} and product.companyid =#{companyId,jdbcType=INTEGER} and warehouse.companyId=#{companyId,jdbcType=INTEGER}
+    and ${con}
+  </insert>
+
+  <select id="getPurcpriceByProduct"  resultType="double">
+    select pr_purcprice from product where pr_id = #{id}
+  </select>
+
 
 </mapper>

+ 107 - 31
frontend/saas-web/app/view/stock/inventory/EditDataList.js

@@ -1,12 +1,16 @@
 Ext.define('saas.view.stock.inventory.EditDataList', {
     extend: 'Ext.grid.Panel',
     xtype: 'stock-inventory-editdatalist',
+    viewModel: 'stock-inventory-editdatalist',
+
 
     autoScroll: true,
     frame:true,
     layout:'fit',
     dataUrl:'/api/storage/stocktaking/list',
     saveUrl:'/api/storage/stocktaking/save',
+    buildUrl:'/api/storage/stocktaking/build',
+    stockUrl:'/api/storage/stocktaking/stock',
     requires: [
         'Ext.Action',
         'Ext.grid.plugin.CellEditing',
@@ -22,12 +26,21 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
             }
         }
     },
-    tbar: [{		
+    tbar: [{
+        xtype: 'hidden',
+        name: 'wh_id',
+        bind:'{wh_id}',
+        fieldLabel: 'wh_id'
+    },{
+        xtype: 'hidden',
+        name: 'wh_code',
+        fieldLabel: 'wh_code'
+    },{		
         xtype: 'warehouseDbfindTrigger',
         name: 'wh_description',
         emptyText: '仓库',
         dbfinds:[{
-            from:'id',to:'id',ignore:true 
+            from:'id',to:'wh_id',ignore:true 
         }, { 
             from:'wh_code',to:'wh_code'
         }, {
@@ -38,7 +51,8 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
         editable:false,
         xtype : "remotecombo", 
         storeUrl:'/api/document/producttype/getCombo',
-        name : "pr_kind", 
+        name : "pr_kind",
+        bind:'{pr_kind}', 
         emptyText : "类型", 
         allowBlank : false, 
         addHandler:function(b){
@@ -59,15 +73,24 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
             this.dialog.show();
         },
         width:150
-    }, {
+    },{
+        xtype: 'hidden',
+        name: 'pr_id',
+        bind:'{pr_id}',
+        fieldLabel: 'pr_id'
+    },{
+        xtype: 'hidden',
+        name: 'pr_code',
+        fieldLabel: 'pr_code'
+    },{
         xtype: 'productDbfindTrigger',
         name: 'pr_detail',
         emptyText:'输入物料编号或名称',
-        width:150,
+        width:200,
         dbfinds:[{
-            from:'pr_detail',to:'pr_detail',
+            from:'id',to:'pr_id',ignore:true
         },{
-            from:'pr_code',to:'pd_prodcode',
+            from:'pr_code',to:'pr_code',
         }, {
             from:'pr_detail',to:'pr_detail'
         }]
@@ -77,19 +100,8 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
         text:'查询',
         listeners: {
             click:function(b){
-                var grid = b.ownerCt.ownerCt;
-                var tbar = b.ownerCt;
-                grid.condition = '';
-                var items = [];
-                var fields = tbar.items.items.map(f => f.name);
-                Ext.each(fields, function(f, index){
-                    var field = tbar.down('[name='+f+']');
-                    if(field){
-                        items.push(field);
-                    }
-                });
-                grid.condition = grid.getCondition(items);
-                grid.store.loadPage(1);
+                var me =this.ownerCt.ownerCt;
+                me.onbuild();
             }
         }
     },'->',{
@@ -114,7 +126,9 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
         text:'生成盘点单据',
         listeners: {
             click:function(b){
-             
+                var me = this.ownerCt.ownerCt;
+                me.onStocking();
+                
             }
         }
     }],
@@ -294,14 +308,12 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
     getCondition: function(items) {
         var me = this,
         conditions = [];
-
         for(var i = 0; i < items.length; i++) {
             var item = items[i];
             var field = item.name,
             func = item.getCondition,
             value = item.value,
             condition;
-
             if(typeof func == 'function') {
                 condition = {
                     type: 'condition',
@@ -343,7 +355,6 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
 
         return type;
     },
-
     getDefaultFieldOperation: function(xtype) {
         var operation;
 
@@ -361,7 +372,6 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
 
         return operation;
     },
-
     /**
      * 处理部分字段值
      */
@@ -386,20 +396,87 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
 
         return conditionValue;
     },
-
     refresh:function(){
-        //debugger
-        var me = this,
+        var me = this;
+        // me.onbuild();
+        me.reload();
+    },
+    reload:function(){
+        var me = this;    
         store = me.getStore();
         store.load();
     },
+    onStocking:function(){
+        var me = this;
+        saas.util.BaseUtil.request({
+            url: me.stockUrl,
+            method: 'GET',
+        })
+        .then(function(localJson) {
+            if(localJson.success){
+                // me.refresh();
+                var intValue = localJson.data.inData.id,
+                codeValue= localJson.data.inData.code,
+                name = localJson.data.inData.name;
+                saas.util.BaseUtil.openTab('stock-otherin-formpanel',name+"("+codeValue+")",codeValue+intValue, {
+                    initId: intValue
+                });
+        
+                intValue = localJson.data.outData.id;
+                codeValue= localJson.data.outData.code;
+                name = localJson.data.outData.name;
+                saas.util.BaseUtil.openTab('stock-otherout-formpanel',name+"("+codeValue+")",codeValue+intValue, {
+                    initId: intValue
+                });
+            }
+        })
+        .catch(function(res) {
+            console.error(res);
+            saas.util.BaseUtil.showToast('生成盘点单失败: ' + res.message);
+        });    
+    },
+    onbuild:function(){
+        var me =this;
+        var grid = me;
+        var tbar = me.dockedItems.items[2];
+        var data;
+        grid.condition = '';
+        var items = [];
+        var fields = tbar.items.items.map(f => f.name);
+        Ext.each(fields, function(f, index){
+            var field = tbar.down('[name='+f+']');
+            if(field){
+                items.push(field);
+            }
+        });
+        grid.condition = grid.getCondition(items);
+
+        var data = grid.condition;
+        param = {
+            mode:'MAIN',
+            condition: JSON.stringify(data)
+        }
+        saas.util.BaseUtil.request({
+            url: me.buildUrl,
+            params: JSON.stringify(param),
+            method: 'POST',
+        })
+        .then(function(localJson) {
+            if(localJson.success){
+                me.reload();
+            }
+        })
+        .catch(function(res) {
+            console.error(res);
+            saas.util.BaseUtil.showToast('保存失败: ' + res.message);
+        });        
+    },
     onSave:function(){
         var me = this,
         gridData = me.getDirtyData();
         if(gridData==null){
             saas.util.BaseUtil.showToast('未修改数据');
         }
-
         saas.util.BaseUtil.request({
             url: me.saveUrl,
             params: JSON.stringify(gridData),
@@ -407,7 +484,7 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
         })
         .then(function(localJson) {
             if(localJson.success){
-                me.refresh();
+                me.reload();
             }
         })
         .catch(function(res) {
@@ -424,7 +501,6 @@ Ext.define('saas.view.stock.inventory.EditDataList', {
         Ext.Array.each(allData, function(item){
             var d = Object.assign({}, item.data),
             dirty = item.dirty;
-
             if(dirty){
                 if((typeof d.id) != "number" && d.id.indexOf('-')>-1){
                     d.id = 0;

+ 5 - 0
frontend/saas-web/app/view/stock/inventory/EditDataListModel.js

@@ -0,0 +1,5 @@
+Ext.define('saas.view.stock.inventory.EditDataListModel', {
+    extend: 'Ext.app.ViewModel',
+    alias: 'viewmodel.stock-inventory-editdatalist',
+    
+});

+ 1 - 1
frontend/saas-web/app/view/stock/otherIn/FormPanel.js

@@ -72,7 +72,7 @@ Ext.define('saas.view.stock.otherIn.FormPanel', {
         xtype: 'vendorDbfindTrigger',
         name: 'pi_vendname',
         fieldLabel: '供应商名称',
-        allowBlank : false,
+        allowBlank : true,
     },{
         xtype : "datefield", 
         name : "pi_date", 

+ 1 - 1
frontend/saas-web/app/view/stock/otherOut/FormPanel.js

@@ -56,7 +56,7 @@ Ext.define('saas.view.stock.otherOut.FormPanel', {
         xtype: 'customerDbfindTrigger',
         name: 'pi_custname',
         bind: '{pi_custname}',
-        allowBlank : false,
+        allowBlank : true,
         fieldLabel: '客户名称'
     }, {
         xtype: "datefield",