diff --git a/erp-modular/src/main/java/com/skyeye/controller/MemberController.java b/erp-modular/src/main/java/com/skyeye/controller/MemberController.java index f2c57f52..39df3e0e 100644 --- a/erp-modular/src/main/java/com/skyeye/controller/MemberController.java +++ b/erp-modular/src/main/java/com/skyeye/controller/MemberController.java @@ -114,4 +114,17 @@ public class MemberController { public void queryMemberByIdAndInfo(InputObject inputObject, OutputObject outputObject) throws Exception{ memberService.queryMemberByIdAndInfo(inputObject, outputObject); } + + /** + * 获取会员列表信息展示为下拉框 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @RequestMapping("/post/MemberController/queryMemberListToSelect") + @ResponseBody + public void queryMemberListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception{ + memberService.queryMemberListToSelect(inputObject, outputObject); + } + } diff --git a/erp-modular/src/main/java/com/skyeye/controller/RetailOutLetController.java b/erp-modular/src/main/java/com/skyeye/controller/RetailOutLetController.java new file mode 100644 index 00000000..5326af6a --- /dev/null +++ b/erp-modular/src/main/java/com/skyeye/controller/RetailOutLetController.java @@ -0,0 +1,71 @@ +package com.skyeye.controller; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; +import com.skyeye.service.RetailOutLetService; + +/** + * @Author 卫志强 + * @Description 零售出库 + * @Date 2019/10/16 15:32 + */ +@Controller +public class RetailOutLetController { + + @Autowired + private RetailOutLetService retailOutLetService; + + /** + * 获取零售出库列表信息 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @RequestMapping("/post/RetailOutLetController/queryRetailOutLetToList") + @ResponseBody + public void queryRetailOutLetToList(InputObject inputObject, OutputObject outputObject) throws Exception{ + retailOutLetService.queryRetailOutLetToList(inputObject, outputObject); + } + + /** + * 新增零售出库信息 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @RequestMapping("/post/RetailOutLetController/insertRetailOutLetMation") + @ResponseBody + public void insertRetailOutLetMation(InputObject inputObject, OutputObject outputObject) throws Exception{ + retailOutLetService.insertRetailOutLetMation(inputObject, outputObject); + } + + /** + * 编辑零售出库信息时进行回显 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @RequestMapping("/post/RetailOutLetController/queryRetailOutLetMationToEditById") + @ResponseBody + public void queryRetailOutLetMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception{ + retailOutLetService.queryRetailOutLetMationToEditById(inputObject, outputObject); + } + + /** + * 编辑零售出库信息 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @RequestMapping("/post/RetailOutLetController/editRetailOutLetMationById") + @ResponseBody + public void editRetailOutLetMationById(InputObject inputObject, OutputObject outputObject) throws Exception{ + retailOutLetService.editRetailOutLetMationById(inputObject, outputObject); + } + +} diff --git a/erp-modular/src/main/java/com/skyeye/dao/MemberDao.java b/erp-modular/src/main/java/com/skyeye/dao/MemberDao.java index d1f4c29e..289bb285 100644 --- a/erp-modular/src/main/java/com/skyeye/dao/MemberDao.java +++ b/erp-modular/src/main/java/com/skyeye/dao/MemberDao.java @@ -33,4 +33,6 @@ public interface MemberDao { public Map queryMemberByEnabled(Map params) throws Exception; public Map queryMemberByIdAndInfo(Map params) throws Exception; + + public List> queryMemberListToSelect(Map params) throws Exception; } diff --git a/erp-modular/src/main/java/com/skyeye/dao/RetailOutLetDao.java b/erp-modular/src/main/java/com/skyeye/dao/RetailOutLetDao.java new file mode 100644 index 00000000..f1aabac6 --- /dev/null +++ b/erp-modular/src/main/java/com/skyeye/dao/RetailOutLetDao.java @@ -0,0 +1,26 @@ +package com.skyeye.dao; + +import java.util.List; +import java.util.Map; + +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; + +public interface RetailOutLetDao { + + public List> queryRetailOutLetToList(Map params, PageBounds pageBounds) throws Exception; + + public Map queryMaterialsById(Map bean) throws Exception; + + public int insertRetailOutLetMation(Map depothead) throws Exception; + + public int insertRetailOutLetChildMation(List> entitys) throws Exception; + + public Map queryRetailOutLetMationToEditById(Map map) throws Exception; + + public List> queryRetailOutLetItemMationToEditById(Map bean) throws Exception; + + public int deleteRetailOutLetChildMation(Map bean) throws Exception; + + public int editRetailOutLetMationById(Map depothead) throws Exception; + +} diff --git a/erp-modular/src/main/java/com/skyeye/erp/util/ErpConstants.java b/erp-modular/src/main/java/com/skyeye/erp/util/ErpConstants.java index 9c530f26..6a6b5ac3 100644 --- a/erp-modular/src/main/java/com/skyeye/erp/util/ErpConstants.java +++ b/erp-modular/src/main/java/com/skyeye/erp/util/ErpConstants.java @@ -25,7 +25,7 @@ public class ErpConstants { OUT_IS_SALES_OUTLET("销售出库", "XSCK", "5"), OUT_IS_PURCHASE_RETURNS("采购退货", "CGTH", "6"), OUT_IS_ALLOCATION("调拨", "DBCK", "7"), - OUT_IS_RETAIL("零售", "LSCK", "8"), + OUT_IS_RETAIL("零售出库", "LSCK", "8"), OUT_IS_OTHERS("其他出库", "QTCK", "9"), //采购单 PURCHASE_ORDER("采购订单", "CGDD", "10"), diff --git a/erp-modular/src/main/java/com/skyeye/service/MemberService.java b/erp-modular/src/main/java/com/skyeye/service/MemberService.java index aab1057d..0699fb7c 100644 --- a/erp-modular/src/main/java/com/skyeye/service/MemberService.java +++ b/erp-modular/src/main/java/com/skyeye/service/MemberService.java @@ -24,4 +24,6 @@ public interface MemberService { public void editMemberByNotEnabled(InputObject inputObject, OutputObject outputObject) throws Exception; public void queryMemberByIdAndInfo(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void queryMemberListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception; } diff --git a/erp-modular/src/main/java/com/skyeye/service/RetailOutLetService.java b/erp-modular/src/main/java/com/skyeye/service/RetailOutLetService.java new file mode 100644 index 00000000..41e3c5ea --- /dev/null +++ b/erp-modular/src/main/java/com/skyeye/service/RetailOutLetService.java @@ -0,0 +1,16 @@ +package com.skyeye.service; + +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; + +public interface RetailOutLetService { + + public void queryRetailOutLetToList(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void insertRetailOutLetMation(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void queryRetailOutLetMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception; + + public void editRetailOutLetMationById(InputObject inputObject, OutputObject outputObject) throws Exception; + +} diff --git a/erp-modular/src/main/java/com/skyeye/service/impl/MemberServiceImpl.java b/erp-modular/src/main/java/com/skyeye/service/impl/MemberServiceImpl.java index 16fb3226..69b5ac7b 100644 --- a/erp-modular/src/main/java/com/skyeye/service/impl/MemberServiceImpl.java +++ b/erp-modular/src/main/java/com/skyeye/service/impl/MemberServiceImpl.java @@ -180,4 +180,19 @@ public class MemberServiceImpl implements MemberService { outputObject.setBean(bean); outputObject.settotal(1); } + + /** + * 获取会员列表信息展示为下拉框 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @Override + public void queryMemberListToSelect(InputObject inputObject, OutputObject outputObject) throws Exception { + Map params = inputObject.getParams(); + params.put("userId", inputObject.getLogParams().get("id")); + List> beans = memberDao.queryMemberListToSelect(params); + outputObject.setBeans(beans); + outputObject.settotal(beans.size()); + } } diff --git a/erp-modular/src/main/java/com/skyeye/service/impl/RetailOutLetServiceImpl.java b/erp-modular/src/main/java/com/skyeye/service/impl/RetailOutLetServiceImpl.java new file mode 100644 index 00000000..dbc0034f --- /dev/null +++ b/erp-modular/src/main/java/com/skyeye/service/impl/RetailOutLetServiceImpl.java @@ -0,0 +1,222 @@ +package com.skyeye.service.impl; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; +import com.github.miemiedev.mybatis.paginator.domain.PageList; +import com.skyeye.common.object.InputObject; +import com.skyeye.common.object.OutputObject; +import com.skyeye.common.util.ToolUtil; +import com.skyeye.dao.RetailOutLetDao; +import com.skyeye.erp.util.ErpConstants; +import com.skyeye.erp.util.ErpOrderNum; +import com.skyeye.service.RetailOutLetService; + +import net.sf.json.JSONArray; + +@Service +public class RetailOutLetServiceImpl implements RetailOutLetService{ + + @Autowired + private RetailOutLetDao retailOutLetDao; + + /** + * 获取零售出库列表信息 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @Override + public void queryRetailOutLetToList(InputObject inputObject, OutputObject outputObject) throws Exception { + Map params = inputObject.getParams(); + params.put("userId", inputObject.getLogParams().get("id")); + List> beans = retailOutLetDao.queryRetailOutLetToList(params, + new PageBounds(Integer.parseInt(params.get("page").toString()), Integer.parseInt(params.get("limit").toString()))); + PageList> beansPageList = (PageList>)beans; + int total = beansPageList.getPaginator().getTotalCount(); + outputObject.setBeans(beans); + outputObject.settotal(total); + } + + /** + * 新增零售出库信息 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @SuppressWarnings("unchecked") + @Override + @Transactional(value="transactionManager") + public void insertRetailOutLetMation(InputObject inputObject, OutputObject outputObject) throws Exception { + Map map = inputObject.getParams(); + String depotheadStr = map.get("depotheadStr").toString();//零售产品列表 + if(ToolUtil.isJson(depotheadStr)){ + String useId = ToolUtil.getSurFaceId();//单据主表id + String userId = inputObject.getLogParams().get("id").toString(); + //处理数据 + JSONArray jArray = JSONArray.fromObject(depotheadStr); + //产品中间转换对象,单据子表存储对象 + Map bean, entity; + List> entitys = new ArrayList<>();//单据子表实体集合信息 + BigDecimal allPrice = new BigDecimal("0");//主单总价 + BigDecimal itemAllPrice = null;//子单对象 + for(int i = 0; i < jArray.size(); i++){ + bean = jArray.getJSONObject(i); + entity = retailOutLetDao.queryMaterialsById(bean); + if(entity != null && !entity.isEmpty()){ + //获取单价 + itemAllPrice = new BigDecimal(bean.get("estimateSalePrice").toString()); + entity.put("id", ToolUtil.getSurFaceId()); + entity.put("headerId", useId);//单据主表id + entity.put("operNumber", bean.get("rkNum"));//数量 + //计算子单总价:单价*数量 + itemAllPrice = itemAllPrice.multiply(new BigDecimal(bean.get("rkNum").toString())); + entity.put("allPrice", itemAllPrice);//单据子表总价 + entity.put("estimateSalePrice", bean.get("estimateSalePrice"));//单价 + entity.put("remark", bean.get("remark"));//备注 + entity.put("depotId", bean.get("depotId"));//仓库 + entity.put("mType", 0);//商品类型 0.普通 1.组合件 2.普通子件 + entity.put("userId", userId); + entity.put("deleteFlag", 0);//删除标记,0未删除,1删除 + entitys.add(entity); + //计算主单总价 + allPrice = allPrice.add(itemAllPrice); + } + } + if(entitys.size() == 0){ + outputObject.setreturnMessage("请选择产品"); + return; + } + //单据主表对象 + Map depothead = new HashMap<>(); + depothead.put("id", useId); + depothead.put("type", 1);//类型(1.出库/2.入库) + depothead.put("subType", ErpConstants.DepoTheadSubType.OUT_IS_RETAIL.getNum());//零售出库 + ErpOrderNum erpOrderNum = new ErpOrderNum(); + String orderNum = erpOrderNum.getOrderNumBySubType(userId, ErpConstants.DepoTheadSubType.OUT_IS_RETAIL.getNum()); + depothead.put("defaultNumber", orderNum);//初始票据号 + depothead.put("number", orderNum);//票据号 + depothead.put("operPersonId", userId);//操作员id + depothead.put("operPersonName", inputObject.getLogParams().get("userName"));//操作员名字 + depothead.put("createTime", ToolUtil.getTimeAndToString());//创建时间 + depothead.put("operTime", map.get("operTime"));//零售出库时间即单据日期 + depothead.put("organId", map.get("supplierId"));//会员Id + depothead.put("accountId", map.get("accountId"));//账户Id + depothead.put("remark", map.get("remark"));//备注 + depothead.put("payType", map.get("payType"));//付款类型 + depothead.put("changeAmount", map.get("changeAmount"));//本次付款金额 + depothead.put("totalPrice", allPrice);//合计金额 + depothead.put("giveChange", map.get("giveChange"));//找零金额 + depothead.put("status", "2");//状态,0未审核、1.审核中、2.审核通过、3.审核拒绝、4.已转采购|销售 + depothead.put("userId", userId); + depothead.put("deleteFlag", 0);//删除标记,0未删除,1删除 + retailOutLetDao.insertRetailOutLetMation(depothead); + retailOutLetDao.insertRetailOutLetChildMation(entitys); + }else{ + outputObject.setreturnMessage("数据格式错误"); + } + } + + /** + * 编辑零售出库信息时进行回显 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @Override + public void queryRetailOutLetMationToEditById(InputObject inputObject, OutputObject outputObject) throws Exception { + Map map = inputObject.getParams(); + map.put("userId", inputObject.getLogParams().get("id")); + //获取主表信息 + Map bean = retailOutLetDao.queryRetailOutLetMationToEditById(map); + if(bean != null && !bean.isEmpty()){ + //获取子表信息 + List> norms = retailOutLetDao.queryRetailOutLetItemMationToEditById(bean); + bean.put("items", norms); + outputObject.setBean(bean); + outputObject.settotal(1); + }else{ + outputObject.setreturnMessage("该数据已不存在."); + } + } + + /** + * 编辑零售出库信息 + * @param inputObject + * @param outputObject + * @throws Exception + */ + @SuppressWarnings("unchecked") + @Override + @Transactional(value="transactionManager") + public void editRetailOutLetMationById(InputObject inputObject, OutputObject outputObject) throws Exception { + Map map = inputObject.getParams(); + String depotheadStr = map.get("depotheadStr").toString();//零售产品列表 + if(ToolUtil.isJson(depotheadStr)){ + String useId = map.get("id").toString();//单据主表id + String userId = inputObject.getLogParams().get("id").toString(); + //处理数据 + JSONArray jArray = JSONArray.fromObject(depotheadStr); + //产品中间转换对象,单据子表存储对象 + Map bean, entity; + List> entitys = new ArrayList<>();//单据子表实体集合信息 + BigDecimal allPrice = new BigDecimal("0");//主单总价 + BigDecimal itemAllPrice = null;//子单对象 + for(int i = 0; i < jArray.size(); i++){ + bean = jArray.getJSONObject(i); + entity = retailOutLetDao.queryMaterialsById(bean); + if(entity != null && !entity.isEmpty()){ + //获取单价 + itemAllPrice = new BigDecimal(bean.get("estimateSalePrice").toString()); + entity.put("id", ToolUtil.getSurFaceId()); + entity.put("headerId", useId);//单据主表id + entity.put("operNumber", bean.get("rkNum"));//数量 + //计算子单总价:单价*数量 + itemAllPrice = itemAllPrice.multiply(new BigDecimal(bean.get("rkNum").toString())); + entity.put("allPrice", itemAllPrice);//单据子表总价 + entity.put("estimateSalePrice", bean.get("estimateSalePrice"));//单价 + entity.put("remark", bean.get("remark"));//备注 + entity.put("depotId", bean.get("depotId"));//仓库 + entity.put("mType", 0);//商品类型 0.普通 1.组合件 2.普通子件 + entity.put("userId", userId); + entity.put("deleteFlag", 0);//删除标记,0未删除,1删除 + entitys.add(entity); + //计算主单总价 + allPrice = allPrice.add(itemAllPrice); + } + } + if(entitys.size() == 0){ + outputObject.setreturnMessage("请选择产品"); + return; + } + //单据主表对象 + Map depothead = new HashMap<>(); + depothead.put("id", useId); + depothead.put("operTime", map.get("operTime"));//零售出库时间即单据日期 + depothead.put("organId", map.get("supplierId"));//会员Id + depothead.put("accountId", map.get("accountId"));//账户Id + depothead.put("remark", map.get("remark"));//备注 + depothead.put("payType", map.get("payType"));//付款类型 + depothead.put("changeAmount", map.get("changeAmount"));//本次付款金额 + depothead.put("totalPrice", allPrice);//合计金额 + depothead.put("giveChange", map.get("giveChange"));//找零金额 + depothead.put("userId", userId); + //删除之前绑定的产品 + retailOutLetDao.deleteRetailOutLetChildMation(map); + //重新添加 + retailOutLetDao.editRetailOutLetMationById(depothead); + retailOutLetDao.insertRetailOutLetChildMation(entitys); + }else{ + outputObject.setreturnMessage("数据格式错误"); + } + } + +} diff --git a/erp-modular/src/main/java/com/skyeye/service/impl/SalesOutLetServiceImpl.java b/erp-modular/src/main/java/com/skyeye/service/impl/SalesOutLetServiceImpl.java index f1a4221b..593eb4ac 100644 --- a/erp-modular/src/main/java/com/skyeye/service/impl/SalesOutLetServiceImpl.java +++ b/erp-modular/src/main/java/com/skyeye/service/impl/SalesOutLetServiceImpl.java @@ -118,7 +118,7 @@ public class SalesOutLetServiceImpl implements SalesOutLetService{ depothead.put("operPersonName", inputObject.getLogParams().get("userName"));//操作员名字 depothead.put("createTime", ToolUtil.getTimeAndToString());//创建时间 depothead.put("operTime", map.get("operTime"));//销售出库时间即单据日期 - depothead.put("organId", map.get("supplierId"));//供应商Id + depothead.put("organId", map.get("supplierId"));//客户Id depothead.put("accountId", map.get("accountId"));//账户Id depothead.put("remark", map.get("remark"));//备注 depothead.put("payType", map.get("payType"));//付款类型 @@ -238,7 +238,7 @@ public class SalesOutLetServiceImpl implements SalesOutLetService{ Map depothead = new HashMap<>(); depothead.put("id", useId); depothead.put("operTime", map.get("operTime"));//销售出库时间即单据日期 - depothead.put("organId", map.get("supplierId"));//供应商Id + depothead.put("organId", map.get("supplierId"));//客户Id depothead.put("accountId", map.get("accountId"));//账户Id depothead.put("remark", map.get("remark"));//备注 depothead.put("payType", map.get("payType"));//付款类型 diff --git a/erp-modular/src/main/resources/dbmapper/erp/ErpCommonMapper.xml b/erp-modular/src/main/resources/dbmapper/erp/ErpCommonMapper.xml index 68876f8e..6f71aac1 100644 --- a/erp-modular/src/main/resources/dbmapper/erp/ErpCommonMapper.xml +++ b/erp-modular/src/main/resources/dbmapper/erp/ErpCommonMapper.xml @@ -18,6 +18,7 @@ a.status_content statusContent, a.link_number linkNumber, FORMAT(a.change_amount, 2) changeAmount, + FORMAT(a.give_change, 2) giveChange, FORMAT(a.discount, 2) discount, FORMAT(a.discount_money, 2) discountMoney, FORMAT(a.discount_last_money, 2) discountLastMoney, diff --git a/erp-modular/src/main/resources/dbmapper/erp/MemberMapper.xml b/erp-modular/src/main/resources/dbmapper/erp/MemberMapper.xml index 43c09b61..ae7f1456 100644 --- a/erp-modular/src/main/resources/dbmapper/erp/MemberMapper.xml +++ b/erp-modular/src/main/resources/dbmapper/erp/MemberMapper.xml @@ -274,4 +274,17 @@ AND s.type = 3 ORDER BY s.id DESC LIMIT 0,1 + + + \ No newline at end of file diff --git a/erp-modular/src/main/resources/dbmapper/erp/RetailOutLetMapper.xml b/erp-modular/src/main/resources/dbmapper/erp/RetailOutLetMapper.xml new file mode 100644 index 00000000..9809ed6f --- /dev/null +++ b/erp-modular/src/main/resources/dbmapper/erp/RetailOutLetMapper.xml @@ -0,0 +1,159 @@ + + + + + + + + + + INSERT into erp_depothead + (id, `type`, sub_type, default_number, number, oper_person_id, oper_person_name, create_time, oper_time, organ_id, account_id, total_price, + pay_type, remark, status, tenant_id, delete_flag, + change_amount, give_change) + VALUES(#{id}, #{type}, #{subType}, #{defaultNumber}, #{number}, #{operPersonId}, #{operPersonName}, #{createTime}, #{operTime}, #{organId}, #{accountId}, #{totalPrice}, + #{payType}, #{remark}, #{status}, #{userId}, #{deleteFlag}, + #{changeAmount}, #{giveChange}) + + + + INSERT INTO erp_depotitem + (id, header_id, material_id, material_name, material_model, m_unit_id, oper_number, basic_number, unit_price, all_price, remark, depot_id, + m_type, tenant_id, delete_flag) + values + + (#{item.id}, #{item.headerId}, #{item.materialId}, #{item.materialName}, #{item.materialModel}, #{item.mUnitId}, #{item.operNumber}, #{item.baseNumber}, #{item.estimateSalePrice}, #{item.allPrice}, #{item.remark}, #{item.depotId}, + #{item.mType}, #{item.userId}, #{item.deleteFlag}) + + + + + + + + + DELETE + FROM + erp_depotitem + WHERE + header_id = #{id} + + + + UPDATE erp_depothead + + + oper_time = #{operTime}, + + + organ_id = #{organId}, + + account_id = #{accountId}, + remark = #{remark}, + + pay_type = #{payType}, + + + total_price = #{totalPrice}, + + change_amount = #{changeAmount}, + give_change = #{giveChange}, + + WHERE id = #{id} + AND tenant_id = #{userId} + AND sub_type = '8' + + + \ No newline at end of file diff --git a/erp-modular/src/main/resources/mapping/erp-wei.xml b/erp-modular/src/main/resources/mapping/erp-wei.xml index e80cde16..e1c9bc17 100644 --- a/erp-modular/src/main/resources/mapping/erp-wei.xml +++ b/erp-modular/src/main/resources/mapping/erp-wei.xml @@ -491,6 +491,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/erp-modular/src/main/resources/mapping/erp.xml b/erp-modular/src/main/resources/mapping/erp.xml index ef8ce1d0..d50192da 100644 --- a/erp-modular/src/main/resources/mapping/erp.xml +++ b/erp-modular/src/main/resources/mapping/erp.xml @@ -245,6 +245,8 @@ + + diff --git a/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletadd.js b/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletadd.js new file mode 100644 index 00000000..e1b4101b --- /dev/null +++ b/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletadd.js @@ -0,0 +1,405 @@ +var material = new Array(); //产品集合 + +layui.config({ + base: basePath, + version: skyeyeVersion +}).extend({ //指定js别名 + window: 'js/winui.window' +}).define(['window', 'jquery', 'winui', 'laydate'], function(exports) { + winui.renderColor(); + layui.use(['form'], function(form) { + var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 + var $ = layui.$, + laydate = layui.laydate; + var enclosureInfo = ""; //附件id + var rowNum = 1; //表格的序号 + var depotHtml = "", materialHtml = "";//仓库 + var tockObject = new Array();//根据仓库和规格id查询出来的对应库存信息 + + var usetableTemplate = $("#usetableTemplate").html(); + var selOption = getFileContent('tpl/template/select-option.tpl'); + + //单据时间 + laydate.render({ + elem: '#operTime', + type: 'datetime', + value: getFormatDate(), + trigger: 'click' + }); + + initAccountHtml(); + //初始化账户 + function initAccountHtml() { + AjaxPostUtil.request({url: reqBasePath + "account009", params: {}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + //加载账户数据 + $("#accountId").html(getDataUseHandlebars(selOption, json)); + //初始化会员 + initSupplierHtml(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + + //初始化会员 + function initSupplierHtml() { + AjaxPostUtil.request({url: reqBasePath + "member009", params: {}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + //加载会员数据 + $("#supplierId").html(getDataUseHandlebars(selOption, json)); + //初始化仓库 + initDepotHtml(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + + //初始化仓库 + function initDepotHtml() { + AjaxPostUtil.request({url: reqBasePath + "storehouse008", params: {}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + //加载仓库数据 + depotHtml = getDataUseHandlebars(selOption, json); + //初始化产品 + initMaterialHtml(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + + //初始化产品 + function initMaterialHtml() { + AjaxPostUtil.request({url: reqBasePath + "material010", params: {}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + material = json.rows; + //加载产品数据 + materialHtml = getDataUseHandlebars(selOption, json); + //渲染 + form.render(); + //初始化一行数据 + addRow(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + + //仓库加载变化事件 + form.on('select(selectDepotProperty)', function(data) { + var thisRowNum = data.elem.id.replace("depotId", "");//获取当前行 + var thisRowValue = data.value; + loadTockByDepotAndMUnit(thisRowNum); + }); + + //产品加载变化事件 + form.on('select(selectMaterialProperty)', function(data) { + var thisRowNum = data.elem.id.replace("materialId", "");//获取当前行 + var thisRowValue = data.value; + if(!isNull(thisRowValue) && thisRowValue != '请选择') { + $.each(material, function(i, item) { + if(thisRowValue == item.id){ + $("#unitId" + thisRowNum).html(getDataUseHandlebars(selOption, {rows: item.unitList})); + var rkNum = parseInt($("#rkNum" + thisRowNum).val()); + //设置默认选中 + if(item.unit == 2){//多单位 + $.each(item.unitList, function(j, bean) { + if(item.firstInUnit == bean.unitId){ + $("#unitId" + thisRowNum).val(bean.id); + $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + return false; + } + }); + }else{//不是多单位 + var firstItem = item.unitList[0]; + $("#unitId" + thisRowNum).val(firstItem.id); + $("#unitPrice" + thisRowNum).val(firstItem.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(firstItem.estimatePurchasePrice)).toFixed(2));//金额 + } + form.render('select'); + return false; + } + }); + } else { + $("#unitId" + thisRowNum).html(""); //重置规格为空 + form.render('select'); + } + //加载库存 + loadTockByDepotAndMUnit(thisRowNum); + //计算价格 + calculatedTotalPrice(); + }); + + //产品规格加载变化事件 + form.on('select(selectUnitProperty)', function(data) { + var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行 + var thisRowValue = data.value; + //当前选中的产品id + var chooseMaterialId = $("#materialId" + thisRowNum).val(); + if(!isNull(thisRowValue) && thisRowValue != '请选择') { + $.each(material, function(i, item) { + if(chooseMaterialId == item.id){//获取产品 + $.each(item.unitList, function(j, bean) { + if(thisRowValue == bean.id){//获取规格 + //获取当前行数量 + var rkNum = parseInt($("#rkNum" + thisRowNum).val()); + $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + return false; + } + }); + return false; + } + }); + } else { + $("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 + $("#amountOfMoney" + thisRowNum).val("0.00");//重置金额为空 + } + //加载库存 + loadTockByDepotAndMUnit(thisRowNum); + //计算价格 + calculatedTotalPrice(); + }); + + /** + * 根据仓库和规格加载库存 + * @param rowNum 表格行坐标 + */ + function loadTockByDepotAndMUnit(rowNum){ + //获取当前选中的仓库 + var chooseDepotId = $("#depotId" + rowNum).val(); + //获取当前选中的规格 + var chooseUnitId = $("#unitId" + rowNum).val(); + //当两个都不为空时 + if(!isNull(chooseDepotId) && !isNull(chooseUnitId)){ + var inTockObject = -1; + $.each(tockObject, function(i, item){ + if(item.depotId == chooseDepotId && item.unitId == chooseUnitId){ + inTockObject = i; + $("#currentTock" + rowNum).html(item.currentTock); + return false; + } + }); + //如果数组中不包含对应的库存 + if(inTockObject < 0){ + //获取库存 + AjaxPostUtil.request({url: reqBasePath + "material011", params: {depotId: chooseDepotId, mUnitId: chooseUnitId}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + var currentTock = 0; + if(!isNull(json.bean)){ + currentTock = json.bean.currentTock; + } + tockObject.push({ + depotId: chooseDepotId, + unitId: chooseUnitId, + currentTock: currentTock + }); + $("#currentTock" + rowNum).html(currentTock); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + }else{ + //否则重置库存为空 + $("#currentTock" + rowNum).html(""); + } + } + + var showTdByEdit = 'rkNum';//根据那一列的值进行变化,默认根据数量 + //数量变化 + $("body").on("input", ".rkNum, .unitPrice, .amountOfMoney", function() { + if($(this).attr("class").replace("layui-input change-input ", "") != showTdByEdit){ + showTdByEdit = $(this).attr("class").replace("layui-input change-input ", ""); + $(".change-input").parent().removeAttr("style"); + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } + calculatedTotalPrice(); + }); + $("body").on("change", ".rkNum, .unitPrice, .amountOfMoney", function() { + if($(this).attr("class").replace("layui-input change-input ", "") != showTdByEdit){ + showTdByEdit = $(this).attr("class").replace("layui-input change-input ", ""); + $(".change-input").parent().removeAttr("style"); + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } + calculatedTotalPrice(); + }); + + //收款金额变化 + $("body").on("input", "#changeAmount", function() { + calculatedTotalPrice(); + }); + $("body").on("change", "#changeAmount", function() { + calculatedTotalPrice(); + }); + + //计算总价 + function calculatedTotalPrice(){ + var rowTr = $("#useTable tr"); + var allPrice = 0; + $.each(rowTr, function(i, item) { + //获取行坐标 + var rowNum = $(item).attr("trcusid").replace("tr", ""); + //获取数量 + var rkNum = parseInt(isNull($("#rkNum" + rowNum).val()) ? "0" : $("#rkNum" + rowNum).val()); + //获取单价 + var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).val()) ? "0" : $("#unitPrice" + rowNum).val()); + //获取单价 + var amountOfMoney = parseFloat(isNull($("#amountOfMoney" + rowNum).val()) ? "0" : $("#amountOfMoney" + rowNum).val()); + if("rkNum" === showTdByEdit){//数量 + //输出金额 + $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + }else if("unitPrice" === showTdByEdit){//单价 + //输出金额 + $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + }else if("amountOfMoney" === showTdByEdit){//金额 + //输出单价 + $("#unitPrice" + rowNum).val((amountOfMoney / rkNum).toFixed(2)); + } + allPrice += parseFloat($("#amountOfMoney" + rowNum).val()); + }); + //获取收款金额 + var changeAmount = parseFloat(isNull($("#changeAmount").val()) ? "0" : $("#changeAmount").val()); + $("#allPrice").html(allPrice.toFixed(2)); + $("#giveChange").html((changeAmount - allPrice).toFixed(2)); + } + + form.on('submit(formAddBean)', function(data) { + //表单验证 + if(winui.verifyForm(data.elem)) { + //获取已选用品数据 + var rowTr = $("#useTable tr"); + if(rowTr.length == 0) { + winui.window.msg('请选择产品.', {icon: 2, time: 2000}); + return false; + } + var tableData = new Array(); + var noError = false; //循环遍历表格数据时,是否有其他错误信息 + $.each(rowTr, function(i, item) { + //获取行编号 + var rowNum = $(item).attr("trcusid").replace("tr", ""); + if(parseInt($("#rkNum" + rowNum).val()) == 0) { + $("#rkNum" + rowNum).addClass("layui-form-danger"); + $("#rkNum" + rowNum).focus(); + winui.window.msg('数量不能为0', {icon: 2, time: 2000}); + noError = true; + return false; + } + if(parseInt($("#rkNum" + rowNum).val()) > parseInt($("#currentTock" + rowNum).html())){ + $("#rkNum" + rowNum).addClass("layui-form-danger"); + $("#rkNum" + rowNum).focus(); + winui.window.msg('超过库存数量.', {icon: 2, time: 2000}); + noError = true; + return false; + } + if(inTableDataArrayByAssetarId($("#materialId" + rowNum).val(), $("#depotId" + rowNum).val(), $("#unitId" + rowNum).val(), tableData)) { + $("#depotId" + rowNum).addClass("layui-form-danger"); + $("#depotId" + rowNum).focus(); + winui.window.msg('一张单中不允许出现相同当库的产品信息,且单位不能重复.', {icon: 2, time: 2000}); + noError = true; + return false; + } + var row = { + depotId: $("#depotId" + rowNum).val(), + materialId: $("#materialId" + rowNum).val(), + mUnitId: $("#unitId" + rowNum).val(), + rkNum: $("#rkNum" + rowNum).val(), + estimateSalePrice: $("#unitPrice" + rowNum).val(), + remark: $("#remark" + rowNum).val() + }; + tableData.push(row); + }); + if(noError) { + return false; + } + + var params = { + supplierId: $("#supplierId").val(), + operTime: $("#operTime").val(), + accountId: $("#accountId").val(), + payType: $("#payType").val(), + remark: $("#remark").val(), + depotheadStr: JSON.stringify(tableData), + changeAmount: $("#changeAmount").val(), + giveChange: $("#giveChange").html() + }; + AjaxPostUtil.request({url: reqBasePath + "retailoutlet002", params: params, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + parent.layer.close(index); + parent.refreshCode = '0'; + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + return false; + }); + + //判断选中的产品是否也在数组中 + function inTableDataArrayByAssetarId(materialId, depotId, unitId, array) { + var isIn = false; + $.each(array, function(i, item) { + if(item.depotId === depotId && item.mUnitId === unitId && item.materialId === materialId) { + isIn = true; + return false; + } + }); + return isIn; + } + + //新增行 + $("body").on("click", "#addRow", function() { + addRow(); + }); + + //删除行 + $("body").on("click", "#deleteRow", function() { + deleteRow(); + }); + + //新增行 + function addRow() { + var par = { + id: "row" + rowNum.toString(), //checkbox的id + trId: "tr" + rowNum.toString(), //行的id + depotId: "depotId" + rowNum.toString(), //仓库id + materialId: "materialId" + rowNum.toString(), //产品id + unitId: "unitId" + rowNum.toString(), //规格id + currentTock: "currentTock" + rowNum.toString(), //库存id + rkNum: "rkNum" + rowNum.toString(), //数量id + unitPrice: "unitPrice" + rowNum.toString(), //单价id + amountOfMoney: "amountOfMoney" + rowNum.toString(), //金额id + remark: "remark" + rowNum.toString() //备注id + }; + $("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); + //赋值给仓库 + $("#" + "depotId" + rowNum.toString()).html(depotHtml); + //赋值给产品 + $("#" + "materialId" + rowNum.toString()).html(materialHtml); + form.render('select'); + form.render('checkbox'); + rowNum++; + //设置根据某列变化的颜色 + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } + + //删除行 + function deleteRow() { + var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked"); + if(checkRow.length > 0) { + $.each(checkRow, function(i, item) { + $(item).parent().parent().remove(); + }); + } else { + winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); + } + } + + $("body").on("click", "#cancle", function() { + parent.layer.close(index); + }); + }); +}); \ No newline at end of file diff --git a/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletdetails.js b/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletdetails.js new file mode 100644 index 00000000..b7884540 --- /dev/null +++ b/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletdetails.js @@ -0,0 +1,27 @@ + +layui.config({ + base: basePath, + version: skyeyeVersion +}).extend({ //指定js别名 + window: 'js/winui.window' +}).define(['window', 'table', 'jquery', 'winui'], function (exports) { + winui.renderColor(); + layui.use(['form'], function (form) { + var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 + var $ = layui.$; + + var beanTemplate = $("#beanTemplate").html(); + + showGrid({ + id: "showForm", + url: reqBasePath + "erpcommon001", + params: {rowId: parent.rowId}, + pagination: false, + template: beanTemplate, + ajaxSendAfter:function(json){ + form.render(); + } + }); + + }); +}); \ No newline at end of file diff --git a/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletedit.js b/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletedit.js new file mode 100644 index 00000000..80c563ae --- /dev/null +++ b/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletedit.js @@ -0,0 +1,446 @@ +var material = new Array(); //产品集合 + +layui.config({ + base: basePath, + version: skyeyeVersion +}).extend({ //指定js别名 + window: 'js/winui.window' +}).define(['window', 'jquery', 'winui', 'laydate'], function(exports) { + winui.renderColor(); + layui.use(['form'], function(form) { + var index = parent.layer.getFrameIndex(window.name); //获取窗口索引 + var $ = layui.$, + laydate = layui.laydate; + var enclosureInfo = ""; //附件id + var rowNum = 1; //表格的序号 + var depotHtml = "", materialHtml = "";//仓库 + var tockObject = new Array();//根据仓库和规格id查询出来的对应库存信息 + + var usetableTemplate = $("#usetableTemplate").html(); + var beanTemplate = $("#beanTemplate").html(); + var selOption = getFileContent('tpl/template/select-option.tpl'); + + //加载单据数据 + var orderObject = []; + showGrid({ + id: "showForm", + url: reqBasePath + "retailoutlet003", + params: {rowId: parent.rowId}, + pagination: false, + template: beanTemplate, + ajaxSendAfter:function(json){ + //单据时间 + laydate.render({ + elem: '#operTime', + type: 'datetime', + trigger: 'click' + }); + orderObject = json; + initAccountHtml(); + } + }); + + //初始化账户 + function initAccountHtml() { + AjaxPostUtil.request({url: reqBasePath + "account009", params: {}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + //加载账户数据 + $("#accountId").html(getDataUseHandlebars(selOption, json)); + //初始化会员 + initSupplierHtml(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + + //初始化会员 + function initSupplierHtml() { + AjaxPostUtil.request({url: reqBasePath + "member009", params: {}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + //加载会员数据 + $("#supplierId").html(getDataUseHandlebars(selOption, json)); + //初始化仓库 + initDepotHtml(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + + //初始化仓库 + function initDepotHtml() { + AjaxPostUtil.request({url: reqBasePath + "storehouse008", params: {}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + //加载仓库数据 + depotHtml = getDataUseHandlebars(selOption, json); + //初始化产品 + initMaterialHtml(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + + //初始化产品 + function initMaterialHtml() { + AjaxPostUtil.request({url: reqBasePath + "material010", params: {}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + material = json.rows; + //加载产品数据 + materialHtml = getDataUseHandlebars(selOption, json); + //渲染数据到页面 + initDataToShow(); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + + //渲染数据到页面 + function initDataToShow(){ + $("#supplierId").val(orderObject.bean.organId);//会员 + $("#accountId").val(orderObject.bean.accountId);//账户 + $("#payType").val(orderObject.bean.payType);//付款类型 + //渲染列表项 + $.each(orderObject.bean.items, function(i, item){ + addRow(); + $.each(material, function(j, bean) { + if(item.materialId == bean.id){ + $("#unitId" + (rowNum - 1)).html(getDataUseHandlebars(selOption, {rows: bean.unitList})); + $("#unitId" + (rowNum - 1)).val(item.mUnitId);//单位回显 + return false; + } + }); + $("#depotId" + (rowNum - 1)).val(item.depotId);//仓库回显 + $("#materialId" + (rowNum - 1)).val(item.materialId);//产品回显 + $("#currentTock" + (rowNum - 1)).html(item.currentTock);//库存回显 + $("#rkNum" + (rowNum - 1)).val(item.operNumber);//数量回显 + $("#unitPrice" + (rowNum - 1)).val(item.unitPrice.toFixed(2));//单价回显 + $("#amountOfMoney" + (rowNum - 1)).val(item.allPrice.toFixed(2));//金额回显 + $("#remark" + (rowNum - 1)).val(item.remark);//备注回显 + //设置标识 + $("tr[trcusid='tr" + (rowNum - 1) + "']").attr("thisid", item.id); + }); + //渲染 + form.render(); + } + + //仓库加载变化事件 + form.on('select(selectDepotProperty)', function(data) { + var thisRowNum = data.elem.id.replace("depotId", "");//获取当前行 + var thisRowValue = data.value; + loadTockByDepotAndMUnit(thisRowNum); + }); + + //产品加载变化事件 + form.on('select(selectMaterialProperty)', function(data) { + var thisRowNum = data.elem.id.replace("materialId", "");//获取当前行 + var thisRowValue = data.value; + if(!isNull(thisRowValue) && thisRowValue != '请选择') { + $.each(material, function(i, item) { + if(thisRowValue == item.id){ + $("#unitId" + thisRowNum).html(getDataUseHandlebars(selOption, {rows: item.unitList})); + var rkNum = parseInt($("#rkNum" + thisRowNum).val()); + //设置默认选中 + if(item.unit == 2){//多单位 + $.each(item.unitList, function(j, bean) { + if(item.firstInUnit == bean.unitId){ + $("#unitId" + thisRowNum).val(bean.id); + $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + return false; + } + }); + }else{//不是多单位 + var firstItem = item.unitList[0]; + $("#unitId" + thisRowNum).val(firstItem.id); + $("#unitPrice" + thisRowNum).val(firstItem.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(firstItem.estimatePurchasePrice)).toFixed(2));//金额 + } + form.render('select'); + return false; + } + }); + } else { + $("#unitId" + thisRowNum).html(""); //重置规格为空 + form.render('select'); + } + //加载库存 + loadTockByDepotAndMUnit(thisRowNum); + //计算价格 + calculatedTotalPrice(); + }); + + //产品规格加载变化事件 + form.on('select(selectUnitProperty)', function(data) { + var thisRowNum = data.elem.id.replace("unitId", "");//获取当前行 + var thisRowValue = data.value; + //当前选中的产品id + var chooseMaterialId = $("#materialId" + thisRowNum).val(); + if(!isNull(thisRowValue) && thisRowValue != '请选择') { + $.each(material, function(i, item) { + if(chooseMaterialId == item.id){//获取产品 + $.each(item.unitList, function(j, bean) { + if(thisRowValue == bean.id){//获取规格 + //获取当前行数量 + var rkNum = parseInt($("#rkNum" + thisRowNum).val()); + $("#unitPrice" + thisRowNum).val(bean.estimatePurchasePrice.toFixed(2));//单价 + $("#amountOfMoney" + thisRowNum).val((rkNum * parseFloat(bean.estimatePurchasePrice)).toFixed(2));//金额 + return false; + } + }); + return false; + } + }); + } else { + $("#unitPrice" + thisRowNum).val("0.00");//重置单价为空 + $("#amountOfMoney" + thisRowNum).val("0.00");//重置金额为空 + } + //加载库存 + loadTockByDepotAndMUnit(thisRowNum); + //计算价格 + calculatedTotalPrice(); + }); + + /** + * 根据仓库和规格加载库存 + * @param rowNum 表格行坐标 + */ + function loadTockByDepotAndMUnit(rowNum){ + //获取当前选中的仓库 + var chooseDepotId = $("#depotId" + rowNum).val(); + //获取当前选中的规格 + var chooseUnitId = $("#unitId" + rowNum).val(); + //当两个都不为空时 + if(!isNull(chooseDepotId) && !isNull(chooseUnitId)){ + var inTockObject = -1; + $.each(tockObject, function(i, item){ + if(item.depotId == chooseDepotId && item.unitId == chooseUnitId){ + inTockObject = i; + $("#currentTock" + rowNum).html(item.currentTock); + return false; + } + }); + //如果数组中不包含对应的库存 + if(inTockObject < 0){ + //获取库存 + AjaxPostUtil.request({url: reqBasePath + "material011", params: {depotId: chooseDepotId, mUnitId: chooseUnitId}, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + var currentTock = 0; + if(!isNull(json.bean)){ + currentTock = json.bean.currentTock; + } + tockObject.push({ + depotId: chooseDepotId, + unitId: chooseUnitId, + currentTock: currentTock + }); + $("#currentTock" + rowNum).html(currentTock); + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + }else{ + //否则重置库存为空 + $("#currentTock" + rowNum).html(""); + } + } + + var showTdByEdit = 'rkNum';//根据那一列的值进行变化,默认根据数量 + //数量变化 + $("body").on("input", ".rkNum, .unitPrice, .amountOfMoney", function() { + if($(this).attr("class").replace("layui-input change-input ", "") != showTdByEdit){ + showTdByEdit = $(this).attr("class").replace("layui-input change-input ", ""); + $(".change-input").parent().removeAttr("style"); + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } + calculatedTotalPrice(); + }); + $("body").on("change", ".rkNum, .unitPrice, .amountOfMoney", function() { + if($(this).attr("class").replace("layui-input change-input ", "") != showTdByEdit){ + showTdByEdit = $(this).attr("class").replace("layui-input change-input ", ""); + $(".change-input").parent().removeAttr("style"); + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } + calculatedTotalPrice(); + }); + + //收款金额变化 + $("body").on("input", "#changeAmount", function() { + calculatedTotalPrice(); + }); + $("body").on("change", "#changeAmount", function() { + calculatedTotalPrice(); + }); + + //计算总价 + function calculatedTotalPrice(){ + var rowTr = $("#useTable tr"); + var allPrice = 0; + $.each(rowTr, function(i, item) { + //获取行坐标 + var rowNum = $(item).attr("trcusid").replace("tr", ""); + //获取数量 + var rkNum = parseInt(isNull($("#rkNum" + rowNum).val()) ? "0" : $("#rkNum" + rowNum).val()); + //获取单价 + var unitPrice = parseFloat(isNull($("#unitPrice" + rowNum).val()) ? "0" : $("#unitPrice" + rowNum).val()); + //获取单价 + var amountOfMoney = parseFloat(isNull($("#amountOfMoney" + rowNum).val()) ? "0" : $("#amountOfMoney" + rowNum).val()); + if("rkNum" === showTdByEdit){//数量 + //输出金额 + $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + }else if("unitPrice" === showTdByEdit){//单价 + //输出金额 + $("#amountOfMoney" + rowNum).val((rkNum * unitPrice).toFixed(2)); + }else if("amountOfMoney" === showTdByEdit){//金额 + //输出单价 + $("#unitPrice" + rowNum).val((amountOfMoney / rkNum).toFixed(2)); + } + allPrice += parseFloat($("#amountOfMoney" + rowNum).val()); + }); + //获取收款金额 + var changeAmount = parseFloat(isNull($("#changeAmount").val()) ? "0" : $("#changeAmount").val()); + $("#allPrice").html(allPrice.toFixed(2)); + $("#giveChange").html((changeAmount - allPrice).toFixed(2)); + } + + form.on('submit(formEditBean)', function(data) { + //表单验证 + if(winui.verifyForm(data.elem)) { + //获取已选用品数据 + var rowTr = $("#useTable tr"); + if(rowTr.length == 0) { + winui.window.msg('请选择产品.', {icon: 2, time: 2000}); + return false; + } + var tableData = new Array(); + var noError = false; //循环遍历表格数据时,是否有其他错误信息 + $.each(rowTr, function(i, item) { + //获取行编号 + var rowNum = $(item).attr("trcusid").replace("tr", ""); + if(parseInt($("#rkNum" + rowNum).val()) == 0) { + $("#rkNum" + rowNum).addClass("layui-form-danger"); + $("#rkNum" + rowNum).focus(); + winui.window.msg('数量不能为0', {icon: 2, time: 2000}); + noError = true; + return false; + } + if(parseInt($("#rkNum" + rowNum).val()) > parseInt($("#currentTock" + rowNum).html())){ + $("#rkNum" + rowNum).addClass("layui-form-danger"); + $("#rkNum" + rowNum).focus(); + winui.window.msg('超过库存数量.', {icon: 2, time: 2000}); + noError = true; + return false; + } + if(inTableDataArrayByAssetarId($("#materialId" + rowNum).val(), $("#depotId" + rowNum).val(), $("#unitId" + rowNum).val(), tableData)) { + $("#depotId" + rowNum).addClass("layui-form-danger"); + $("#depotId" + rowNum).focus(); + winui.window.msg('一张单中不允许出现相同当库的产品信息,且单位不能重复.', {icon: 2, time: 2000}); + noError = true; + return false; + } + var row = { + depotId: $("#depotId" + rowNum).val(), + materialId: $("#materialId" + rowNum).val(), + mUnitId: $("#unitId" + rowNum).val(), + rkNum: $("#rkNum" + rowNum).val(), + estimateSalePrice: $("#unitPrice" + rowNum).val(), + thisId: isNull($(item).attr("thisid")) ? "" : $(item).attr("thisid"), + remark: $("#remark" + rowNum).val() + }; + tableData.push(row); + }); + if(noError) { + return false; + } + + var params = { + supplierId: $("#supplierId").val(), + operTime: $("#operTime").val(), + accountId: $("#accountId").val(), + payType: $("#payType").val(), + remark: $("#remark").val(), + depotheadStr: JSON.stringify(tableData), + changeAmount: $("#changeAmount").val(), + giveChange: $("#giveChange").html(), + rowId: parent.rowId + }; + AjaxPostUtil.request({url: reqBasePath + "retailoutlet004", params: params, type: 'json', callback: function(json) { + if(json.returnCode == 0) { + parent.layer.close(index); + parent.refreshCode = '0'; + } else { + winui.window.msg(json.returnMessage, {icon: 2, time: 2000}); + } + }}); + } + return false; + }); + + //判断选中的产品是否也在数组中 + function inTableDataArrayByAssetarId(materialId, depotId, unitId, array) { + var isIn = false; + $.each(array, function(i, item) { + if(item.depotId === depotId && item.mUnitId === unitId && item.materialId === materialId) { + isIn = true; + return false; + } + }); + return isIn; + } + + //新增行 + $("body").on("click", "#addRow", function() { + addRow(); + }); + + //删除行 + $("body").on("click", "#deleteRow", function() { + deleteRow(); + }); + + //新增行 + function addRow() { + var par = { + id: "row" + rowNum.toString(), //checkbox的id + trId: "tr" + rowNum.toString(), //行的id + depotId: "depotId" + rowNum.toString(), //仓库id + materialId: "materialId" + rowNum.toString(), //产品id + unitId: "unitId" + rowNum.toString(), //规格id + currentTock: "currentTock" + rowNum.toString(), //库存id + rkNum: "rkNum" + rowNum.toString(), //数量id + unitPrice: "unitPrice" + rowNum.toString(), //单价id + amountOfMoney: "amountOfMoney" + rowNum.toString(), //金额id + remark: "remark" + rowNum.toString() //备注id + }; + $("#useTable").append(getDataUseHandlebars(usetableTemplate, par)); + //赋值给仓库 + $("#" + "depotId" + rowNum.toString()).html(depotHtml); + //赋值给产品 + $("#" + "materialId" + rowNum.toString()).html(materialHtml); + form.render('select'); + form.render('checkbox'); + rowNum++; + //设置根据某列变化的颜色 + $("." + showTdByEdit).parent().css({'background-color': '#e6e6e6'}); + } + + //删除行 + function deleteRow() { + var checkRow = $("#useTable input[type='checkbox'][name='tableCheckRow']:checked"); + if(checkRow.length > 0) { + $.each(checkRow, function(i, item) { + $(item).parent().parent().remove(); + }); + } else { + winui.window.msg('请选择要删除的行', {icon: 2, time: 2000}); + } + } + + $("body").on("click", "#cancle", function() { + parent.layer.close(index); + }); + }); +}); \ No newline at end of file diff --git a/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletlist.js b/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletlist.js new file mode 100644 index 00000000..e61f6308 --- /dev/null +++ b/erp-modular/src/main/resources/template/js/retailoutlet/retailoutletlist.js @@ -0,0 +1,166 @@ + +var rowId = ""; + +//单据的开始时间、结束时间 +var startTime = "", endTime = ""; + +layui.config({ + base: basePath, + version: skyeyeVersion +}).extend({ //指定js别名 + window: 'js/winui.window' +}).define(['window', 'table', 'jquery', 'winui', 'form', 'laydate'], function (exports) { + winui.renderColor(); + var $ = layui.$, + form = layui.form, + laydate = layui.laydate, + table = layui.table; + + laydate.render({ + elem: '#operTime', //指定元素 + range: '~' + }); + + //表格渲染 + table.render({ + id: 'messageTable', + elem: '#messageTable', + method: 'post', + url: reqBasePath + 'retailoutlet001', + where: {defaultNumber: $("#defaultNumber").val(), material: $("#material").val(), startTime: startTime, endTime: endTime}, + even: true, //隔行变色 + page: true, + limits: [8, 16, 24, 32, 40, 48, 56], + limit: 8, + cols: [[ + { title: '序号', type: 'numbers'}, + { field: 'defaultNumber', title: '单据编号', align: 'left', width: 200, templet: function(d){ + return '' + d.defaultNumber + ''; + }}, + { field: 'supplierName', title: '会员', align: 'left', width: 150}, + { field: 'materialNames', title: '产品信息', align: 'left', width: 300}, + { field: 'totalPrice', title: '合计金额', align: 'left', width: 120}, + { field: 'changeAmount', title: '收款', align: 'left', width: 120 }, + { field: 'operPersonName', title: '操作人', align: 'left', width: 100}, + { field: 'operTime', title: '单据日期', align: 'center', width: 140 }, + { title: '操作', fixed: 'right', align: 'center', width: 200, toolbar: '#tableBar'} + ]] + }); + + table.on('tool(messageTable)', function (obj) { //注:tool是工具条事件名,test是table原始容器的属性 lay-filter="对应的值" + var data = obj.data; //获得当前行数据 + var layEvent = obj.event; //获得 lay-event 对应的值 + if (layEvent === 'delete') { //删除 + deletemember(data); + }else if (layEvent === 'details') { //详情 + details(data); + }else if (layEvent === 'edit') { //编辑 + edit(data); + } + }); + + //搜索表单 + form.render(); + form.on('submit(formSearch)', function (data) { + //表单验证 + if (winui.verifyForm(data.elem)) { + loadTable(); + } + return false; + }); + + //删除 + function deletemember(data){ + layer.confirm('确认要删除信息吗?', { icon: 3, title: '删除操作' }, function (index) { + AjaxPostUtil.request({url:reqBasePath + "member004", params: {rowId: data.id}, type:'json', callback:function(json){ + if(json.returnCode == 0){ + winui.window.msg("删除成功。", {icon: 1,time: 2000}); + loadTable(); + }else{ + winui.window.msg(json.returnMessage, {icon: 2,time: 2000}); + } + }}); + }); + } + + //详情 + function edit(data){ + rowId = data.id; + _openNewWindows({ + url: "../../tpl/retailoutlet/retailoutletedit.html", + title: "编辑", + pageId: "retailoutletedit", + area: ['90vw', '90vh'], + callBack: function(refreshCode){ + if (refreshCode == '0') { + winui.window.msg("操作成功", {icon: 1,time: 2000}); + loadTable(); + } else if (refreshCode == '-9999') { + winui.window.msg("操作失败", {icon: 2,time: 2000}); + } + }}); + } + + //详情 + function details(data){ + rowId = data.id; + _openNewWindows({ + url: "../../tpl/retailoutlet/retailoutletdetails.html", + title: "详情", + pageId: "retailoutletdetails", + area: ['90vw', '90vh'], + callBack: function(refreshCode){ + }}); + } + + //添加 + $("body").on("click", "#addBean", function(){ + _openNewWindows({ + url: "../../tpl/retailoutlet/retailoutletadd.html", + title: "新增", + pageId: "retailoutletadd", + area: ['90vw', '90vh'], + callBack: function(refreshCode){ + if (refreshCode == '0') { + winui.window.msg("操作成功", {icon: 1,time: 2000}); + loadTable(); + } else if (refreshCode == '-9999') { + winui.window.msg("操作失败", {icon: 2,time: 2000}); + } + }}); + }); + + $("body").on("click", "#reloadTable", function() { + loadTable(); + }); + + $("body").on("click", "#formSearch", function () { + refreshTable(); + }) + + //刷新 + function loadTable(){ + if(isNull($("#operTime").val())){//一定要记得,当createTime为空时 + startTime = ""; + endTime = ""; + }else { + startTime = $("#operTime").val().split('~')[0].trim() + ' 00:00:00'; + endTime = $("#operTime").val().split('~')[1].trim() + ' 23:59:59'; + } + table.reload("messageTable", {where:{defaultNumber: $("#defaultNumber").val(), material: $("#material").val(), startTime: startTime, endTime: endTime}}); + } + + //搜索 + function refreshTable(){ + if(isNull($("#operTime").val())){//一定要记得,当createTime为空时 + startTime = ""; + endTime = ""; + }else { + startTime = $("#operTime").val().split('~')[0].trim() + ' 00:00:00'; + endTime = $("#operTime").val().split('~')[1].trim() + ' 23:59:59'; + } + table.reload("messageTable", {page: {curr: 1}, where:{defaultNumber: $("#defaultNumber").val(), material: $("#material").val(), startTime: startTime, endTime: endTime}}) + } + + exports('retailoutletlist', {}); +}); diff --git a/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletadd.html b/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletadd.html new file mode 100644 index 00000000..61ae206f --- /dev/null +++ b/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletadd.html @@ -0,0 +1,123 @@ + + + + + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ + +
+
+ + + + + + + + + + + + + + + + +
仓库产品(型号)单位库存数量单价金额备注
+
+
+
+ +
+ 0.00 +
+
+
+ +
+ +
+
+
+ +
+ 0.00 +
+
+
+ +
+ +
+
+
+
+ + +
+
+
+
+ + + + + + + + + \ No newline at end of file diff --git a/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletdetails.html b/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletdetails.html new file mode 100644 index 00000000..9692b6e9 --- /dev/null +++ b/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletdetails.html @@ -0,0 +1,125 @@ + + + + + + + + + + +
+
+ +
+ + + +
+ + + + + \ No newline at end of file diff --git a/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletedit.html b/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletedit.html new file mode 100644 index 00000000..05802963 --- /dev/null +++ b/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletedit.html @@ -0,0 +1,130 @@ + + + + + + + + + + +
+
+ +
+
+ + + + + + + + + + + + \ No newline at end of file diff --git a/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletlist.html b/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletlist.html new file mode 100644 index 00000000..7dfb2e6f --- /dev/null +++ b/erp-modular/src/main/resources/template/tpl/retailoutlet/retailoutletlist.html @@ -0,0 +1,57 @@ + + + + + + + + + + +
+
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+ + + + + \ No newline at end of file diff --git a/erp-web/src/main/resources/application.properties b/erp-web/src/main/resources/application.properties index 5b81dbc9..3709b882 100644 --- a/erp-web/src/main/resources/application.properties +++ b/erp-web/src/main/resources/application.properties @@ -32,22 +32,22 @@ spring.servlet.multipart.max-file-size=10Mb spring.http.multipart.max-request-size=100Mb #redis 1连接信息 -redis.ip1=192.168.0.140 +redis.ip1=192.168.1.140 redis.host1=9000 #redis 2连接信息 -redis.ip2=192.168.0.140 +redis.ip2=192.168.1.140 redis.host2=9001 #redis 3连接信息 -redis.ip3=192.168.0.140 +redis.ip3=192.168.1.140 redis.host3=9002 #redis 4连接信息 -redis.ip4=192.168.0.140 +redis.ip4=192.168.1.140 redis.host4=9003 #redis 5连接信息 -redis.ip5=192.168.0.140 +redis.ip5=192.168.1.140 redis.host5=9004 #redis 6连接信息 -redis.ip6=192.168.0.140 +redis.ip6=192.168.1.140 redis.host6=9005 redis.commandTimeout=1000