优化系统,解决单据选择商品的bug

This commit is contained in:
季圣华
2020-02-17 21:09:41 +08:00
parent 4b61eb59ee
commit 2e7638fe07
7 changed files with 70 additions and 46 deletions

View File

@@ -399,4 +399,13 @@
res = false; res = false;
} }
return res; return res;
}
/**
* 判断一个值是否数字
* @param value
* @returns {boolean}
*/
function myIsNaN(value) {
return typeof value === 'number' && !isNaN(value);
} }

View File

@@ -755,30 +755,9 @@
if(rec && rec.total==1) { if(rec && rec.total==1) {
$(".datagrid-body [field='mBarCode']").click(); //在只有单个商品的时候自动选中 $(".datagrid-body [field='mBarCode']").click(); //在只有单个商品的时候自动选中
} }
//分页后判断下是否有选中的数据行combogrid会依据上一次选中的值进行初始化选中datagrid数据行和设置显示值
var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialExtendId'});
var comboText = $(edMaterial.target).next().find('input.combo-text');
$.ajax({
type: "get",
url: '/material/getMaterialByMeId',
data: {
meId: comboText.val(),
mpList: mPropertyList
},
dataType: "json",
success: function (res) {
if (res && res.MaterialName) {
$(edMaterial.target).next().find('input.combo-text').val(res.MaterialName);
}
}
});
}, },
onSelect:function(index, rowData){ onSelect:function(index, rowData){
// var materialExtendId = $("#depotHeadFM .datagrid-body") materialSelect(rowData);
// .find("[field='MaterialExtendId']").find(".datagrid-editable-input").val();
// if(materialExtendId !=rowData.Id) {
materialSelect(rowData);
// }
} }
} }
} }
@@ -918,6 +897,8 @@
var info = res.data; var info = res.data;
var commodityDecimal = info.commodityDecimal-0; //零售价 var commodityDecimal = info.commodityDecimal-0; //零售价
var purchaseDecimal = info.purchaseDecimal-0; //采购价 var purchaseDecimal = info.purchaseDecimal-0; //采购价
var wholesaleDecimal = info.wholesaleDecimal-0; //销售价
var lowDecimal = info.lowDecimal-0; //最低售价
var commodityUnit = info.commodityUnit; //商品单位 var commodityUnit = info.commodityUnit; //商品单位
body =$("#depotHeadFM .datagrid-body"); body =$("#depotHeadFM .datagrid-body");
footer =$("#depotHeadFM .datagrid-footer"); footer =$("#depotHeadFM .datagrid-footer");
@@ -948,11 +929,11 @@
if(listSubType == "零售" || listSubType == "零售退货") { if(listSubType == "零售" || listSubType == "零售退货") {
detailPrice = commodityDecimal; detailPrice = commodityDecimal;
} }
else if(listTitle == "采购订单列表" || listTitle == "采购入库列表" || listTitle == "销售退货列表" || listTitle == "其它入库列表") { else if(listTitle == "采购订单列表" || listTitle == "采购入库列表" || listTitle == "采购退货列表" || listTitle == "其它入库列表") {
detailPrice = purchaseDecimal; detailPrice = purchaseDecimal;
} }
else if(listTitle == "销售订单列表" || listTitle == "销售出库列表" || listTitle == "采购退货列表" || listTitle == "其它出库列表" || listTitle == "调拨出库列表") { else if(listTitle == "销售订单列表" || listTitle == "销售出库列表" || listTitle == "销售退货列表" || listTitle == "其它出库列表" || listTitle == "调拨出库列表") {
detailPrice = commodityDecimal; detailPrice = wholesaleDecimal;
} }
//单价和总价赋值 //单价和总价赋值
if(!detailPrice) { if(!detailPrice) {
@@ -2314,6 +2295,28 @@
//点击商品下拉框,自动加载数量、单价、金额 //点击商品下拉框,自动加载数量、单价、金额
body.find("[field='Stock']").find(input).prop("readonly","readonly"); body.find("[field='Stock']").find(input).prop("readonly","readonly");
body.find("[field='Unit']").find(input).prop("readonly","readonly"); body.find("[field='Unit']").find(input).prop("readonly","readonly");
//点击商品名称
body.find("[field='MaterialExtendId']").find(input).next().off("mouseup").on("mouseup",function(){
var that = $(this);
var meId = that.find('input.textbox-text').val()-0;
if(myIsNaN(meId)) {
$.ajax({
type: "get",
url: '/material/getMaterialByMeId',
data: {
meId: meId,
mpList: mPropertyList
},
dataType: "json",
success: function (res) {
if (res && res.MaterialName) {
that.find('input.textbox-value').val(meId);
that.find('input.textbox-text').val(res.MaterialName);
}
}
});
}
});
//修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计 //修改数量,自动计算金额和合计,另外计算含税单价、税额、价税合计
body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){ body.find("[field='OperNumber']").find(input).off("keyup").on("keyup",function(){
var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价 var UnitPrice = body.find("[field='UnitPrice']").find(input).val(); //单价
@@ -2425,8 +2428,9 @@
$('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName; $('#materialData').datagrid('getRows')[editIndex]['DepotName'] = DepotName;
//商品信息 //商品信息
var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialExtendId'}); var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialExtendId'});
var MaterialName = $(edMaterial.target).combobox('getText'); var MaterialName = $(edMaterial.target).next().find('input.textbox-text').val();
$('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName; $('#materialData').datagrid('getRows')[editIndex]['MaterialName'] = MaterialName;
//其它信息
$('#materialData').datagrid('endEdit', editIndex); $('#materialData').datagrid('endEdit', editIndex);
editIndex = undefined; editIndex = undefined;
return true; return true;
@@ -2441,6 +2445,10 @@
$('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index); $('#materialData').datagrid('selectRow', index).datagrid('beginEdit', index);
editIndex = index; editIndex = index;
autoReckon(); autoReckon();
setTimeout(function() {
var edMaterial = $('#materialData').datagrid('getEditor', {index:editIndex,field:'MaterialExtendId'});
$(edMaterial.target).next().find('input.textbox-text').mouseup();
},550);
} else { } else {
$('#materialData').datagrid('selectRow', editIndex); $('#materialData').datagrid('selectRow', editIndex);
} }

View File

@@ -217,7 +217,8 @@
var mPropertyList = null; //商品属性列表 var mPropertyList = null; //商品属性列表
var mPropertyListShort = ""; //商品属性列表-传值 var mPropertyListShort = ""; //商品属性列表-传值
var clickType = ""; //记录从哪里点击的类别弹窗 var clickType = ""; //记录从哪里点击的类别弹窗
// var maxBarCode = getMaxBarCode(); var maxBarCode = getMaxBarCode(); //获取当前最大条码
var thisBarCode = maxBarCode; //全局商品条码
//初始化界面 //初始化界面
$(function () { $(function () {
//初始化系统基础信息 //初始化系统基础信息
@@ -1059,7 +1060,7 @@
iconCls:'icon-add', iconCls:'icon-add',
handler:function() handler:function()
{ {
append(); //新增 append(1); //新增
} }
}, },
{ {
@@ -1546,17 +1547,20 @@
} }
//新增 //新增
function append() { function append(type) {
if (endEditing()) { if (endEditing()) {
$('#materialExtendData').datagrid('appendRow', {}); $('#materialExtendData').datagrid('appendRow', {});
editIndex = $('#materialExtendData').datagrid('getRows').length - 1; editIndex = $('#materialExtendData').datagrid('getRows').length - 1;
$('#materialExtendData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex); $('#materialExtendData').datagrid('selectRow', editIndex).datagrid('beginEdit', editIndex);
var ed = $('#materialExtendData').datagrid('getEditor', {index:editIndex,field:'BarCode'}); var ed = $('#materialExtendData').datagrid('getEditor', {index:editIndex,field:'BarCode'});
var thisBarCode = getMaxBarCode(); if(type ==1) {
if(!thisBarCode) { if(thisBarCode) {
thisBarCode = "1000"; thisBarCode = Number(thisBarCode)+1;
} else {
thisBarCode = "1000";
}
} }
$(ed.target).val(Number(thisBarCode)+1); $(ed.target).val(thisBarCode);
} }
} }
@@ -1616,7 +1620,7 @@
//商品价格扩展 //商品价格扩展
function accept(objInfo) { function accept(objInfo) {
append(); append(0);
removeit(); removeit();
if ($("#materialExtendData").datagrid('getChanges').length) { if ($("#materialExtendData").datagrid('getChanges').length) {
if (!CheckData()) if (!CheckData())

View File

@@ -221,12 +221,6 @@ public class DepotItemController {
public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx)throws Exception { public String getOtherInfo(String[] mpArr, DepotItemVo4WithInfoEx diEx)throws Exception {
String materialOther = ""; String materialOther = "";
for (int i = 0; i < mpArr.length; i++) { for (int i = 0; i < mpArr.length; i++) {
if (mpArr[i].equals("颜色")) {
materialOther = materialOther + ((diEx.getMColor() == null || diEx.getMColor().equals("")) ? "" : "(" + diEx.getMColor() + ")");
}
if (mpArr[i].equals("规格")) {
materialOther = materialOther + ((diEx.getMStandard() == null || diEx.getMStandard().equals("")) ? "" : "(" + diEx.getMStandard() + ")");
}
if (mpArr[i].equals("制造商")) { if (mpArr[i].equals("制造商")) {
materialOther = materialOther + ((diEx.getMMfrs() == null || diEx.getMMfrs().equals("")) ? "" : "(" + diEx.getMMfrs() + ")"); materialOther = materialOther + ((diEx.getMMfrs() == null || diEx.getMMfrs().equals("")) ? "" : "(" + diEx.getMMfrs() + ")");
} }

View File

@@ -248,7 +248,7 @@ public class MaterialController {
* @throws Exception * @throws Exception
*/ */
@GetMapping(value = "/getMaterialByMeId") @GetMapping(value = "/getMaterialByMeId")
public JSONObject getMaterialByMeId(@RequestParam("meId") long meId, public JSONObject getMaterialByMeId(@RequestParam(value = "meId", required = false) Long meId,
@RequestParam("mpList") String mpList, @RequestParam("mpList") String mpList,
HttpServletRequest request) throws Exception{ HttpServletRequest request) throws Exception{
JSONObject item = new JSONObject(); JSONObject item = new JSONObject();

View File

@@ -362,6 +362,9 @@ public class MaterialService {
public List<MaterialVo4Unit> findBySelectWithBarCode(String q,Integer offset, Integer rows)throws Exception{ public List<MaterialVo4Unit> findBySelectWithBarCode(String q,Integer offset, Integer rows)throws Exception{
List<MaterialVo4Unit> list =null; List<MaterialVo4Unit> list =null;
try{ try{
if(StringUtil.isNotEmpty(q)) {
q = q.replace("'", "");
}
list= materialMapperEx.findBySelectWithBarCode(q, offset, rows); list= materialMapperEx.findBySelectWithBarCode(q, offset, rows);
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
@@ -372,6 +375,9 @@ public class MaterialService {
public int findBySelectWithBarCodeCount(String q)throws Exception{ public int findBySelectWithBarCodeCount(String q)throws Exception{
int result=0; int result=0;
try{ try{
if(StringUtil.isNotEmpty(q)) {
q = q.replace("'", "");
}
result = materialMapperEx.findBySelectWithBarCodeCount(q); result = materialMapperEx.findBySelectWithBarCodeCount(q);
}catch(Exception e){ }catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]", logger.error("异常码[{}],异常提示[{}],异常[{}]",
@@ -712,10 +718,12 @@ public class MaterialService {
return stock; return stock;
} }
public List<MaterialVo4Unit> getMaterialByMeId(long meId) { public List<MaterialVo4Unit> getMaterialByMeId(Long meId) {
List<MaterialVo4Unit> result = new ArrayList<MaterialVo4Unit>(); List<MaterialVo4Unit> result = new ArrayList<MaterialVo4Unit>();
try{ try{
result= materialMapperEx.getMaterialByMeId(meId); if(meId!=null) {
result= materialMapperEx.getMaterialByMeId(meId);
}
}catch(Exception e){ }catch(Exception e){
JshException.readFail(logger, e); JshException.readFail(logger, e);
} }

View File

@@ -73,7 +73,9 @@
</select> </select>
<select id="findByIdWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap"> <select id="findByIdWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
select m.*,u.UName,me.bar_code m_bar_code, me.commodity_unit, me.purchase_decimal, me.commodity_decimal from jsh_material m select m.*,u.UName,me.bar_code m_bar_code, me.commodity_unit, me.purchase_decimal, me.commodity_decimal,
me.wholesale_decimal, me.low_decimal
from jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1' left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_unit u on m.UnitId=u.id and ifnull(u.delete_Flag,'0') !='1' left join jsh_unit u on m.UnitId=u.id and ifnull(u.delete_Flag,'0') !='1'
where me.id = ${meId} where me.id = ${meId}
@@ -220,12 +222,11 @@
</select> </select>
<select id="getMaterialByMeId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList"> <select id="getMaterialByMeId" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultMapList">
select m.*,me.bar_code m_bar_code,u.uname unitName, mc.name categoryName, org.org_abr select m.*,me.bar_code m_bar_code,u.uname unitName, mc.name categoryName
FROM jsh_material m FROM jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1' left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
left JOIN jsh_unit u on m.UnitId = u.id and ifnull(u.delete_Flag,'0') !='1' left JOIN jsh_unit u on m.UnitId = u.id and ifnull(u.delete_Flag,'0') !='1'
left JOIN jsh_materialcategory mc on m.CategoryId = mc.id and ifnull(mc.status,'0') !='2' left JOIN jsh_materialcategory mc on m.CategoryId = mc.id and ifnull(mc.status,'0') !='2'
left join jsh_organization org on m.orga_id = org.id
where 1=1 where 1=1
<if test="meId != null"> <if test="meId != null">
and me.id = ${meId} and me.id = ${meId}