From 4b61eb59ee0cc9cba143fc801297073dc50acacb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Mon, 17 Feb 2020 00:59:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=95=86=E5=93=81=E6=9D=A1?= =?UTF-8?q?=E7=A0=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/数据库更新记录-方便升级.txt | 38 +- erp_web/css/common.css | 2 +- erp_web/js/common/common.js | 25 + erp_web/js/pages/materials/in_out.js | 343 ++--- erp_web/pages/materials/material.html | 494 ++++---- erp_web/pages/template/init_depot_list.html | 4 +- .../erp/controller/DepotItemController.java | 5 +- .../erp/controller/MaterialController.java | 160 ++- .../controller/MaterialExtendController.java | 71 ++ .../erp/datasource/entities/DepotItem.java | 560 +------- .../datasource/entities/DepotItemExample.java | 167 +-- .../entities/DepotItemVo4WithInfoEx.java | 10 + .../datasource/entities/MaterialExtend.java | 146 +++ .../entities/MaterialExtendExample.java | 1091 ++++++++++++++++ .../datasource/entities/MaterialVo4Unit.java | 70 + .../datasource/mappers/DepotItemMapper.java | 68 +- .../mappers/MaterialExtendMapper.java | 30 + .../mappers/MaterialExtendMapperEx.java | 23 + .../datasource/mappers/MaterialMapperEx.java | 15 +- .../datasource/vo/MaterialExtendVo4List.java | 68 + .../MaterialExtendComponent.java | 64 + .../MaterialExtendResource.java | 15 + .../MaterialExtend/MaterialExtendService.java | 329 +++++ .../service/depotItem/DepotItemService.java | 26 +- .../service/material/MaterialComponent.java | 7 +- .../erp/service/material/MaterialService.java | 112 +- .../java/com/jsh/erp/utils/StringUtil.java | 20 + .../resources/mapper_xml/DepotItemMapper.xml | 1125 ++++++++--------- .../mapper_xml/DepotItemMapperEx.xml | 4 +- .../mapper_xml/MaterialExtendMapper.xml | 353 ++++++ .../mapper_xml/MaterialExtendMapperEx.xml | 55 + .../resources/mapper_xml/MaterialMapperEx.xml | 222 +--- src/test/resources/generatorConfig.xml | 1 + 33 files changed, 3728 insertions(+), 1995 deletions(-) create mode 100644 src/main/java/com/jsh/erp/controller/MaterialExtendController.java create mode 100644 src/main/java/com/jsh/erp/datasource/entities/MaterialExtend.java create mode 100644 src/main/java/com/jsh/erp/datasource/entities/MaterialExtendExample.java create mode 100644 src/main/java/com/jsh/erp/datasource/mappers/MaterialExtendMapper.java create mode 100644 src/main/java/com/jsh/erp/datasource/mappers/MaterialExtendMapperEx.java create mode 100644 src/main/java/com/jsh/erp/datasource/vo/MaterialExtendVo4List.java create mode 100644 src/main/java/com/jsh/erp/service/MaterialExtend/MaterialExtendComponent.java create mode 100644 src/main/java/com/jsh/erp/service/MaterialExtend/MaterialExtendResource.java create mode 100644 src/main/java/com/jsh/erp/service/MaterialExtend/MaterialExtendService.java create mode 100644 src/main/resources/mapper_xml/MaterialExtendMapper.xml create mode 100644 src/main/resources/mapper_xml/MaterialExtendMapperEx.xml diff --git a/docs/数据库更新记录-方便升级.txt b/docs/数据库更新记录-方便升级.txt index a8411009..ace1eb7f 100644 --- a/docs/数据库更新记录-方便升级.txt +++ b/docs/数据库更新记录-方便升级.txt @@ -696,4 +696,40 @@ DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci COMMENT='产品初始库存' AUTO_INCREMENT=48 ROW_FORMAT=COMPACT -; \ No newline at end of file +; + +-- ---------------------------- +-- 增加商品扩展信息表 +-- 时间 2020-02-15 +-- by jishenghua +-- ---------------------------- +CREATE TABLE `jsh_material_extend` ( +`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键' , +`material_id` bigint(20) NULL DEFAULT NULL COMMENT '商品id' , +`bar_code` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商品条码' , +`commodity_unit` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '商品单位' , +`purchase_decimal` decimal(24,6) NULL DEFAULT NULL COMMENT '采购价格' , +`commodity_decimal` decimal(24,6) NULL DEFAULT NULL COMMENT '零售价格' , +`wholesale_decimal` decimal(24,6) NULL DEFAULT NULL COMMENT '销售价格' , +`low_decimal` decimal(24,6) NULL DEFAULT NULL COMMENT '最低售价' , +`create_time` datetime NULL DEFAULT NULL COMMENT '创建日期' , +`create_serial` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '创建人编码' , +`update_serial` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '更新人编码' , +`update_time` bigint(20) NULL DEFAULT NULL COMMENT '更新时间戳' , +`tenant_id` bigint(20) NULL DEFAULT NULL COMMENT '租户id' , +`delete_Flag` varchar(1) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '0' COMMENT '删除标记,0未删除,1删除' , +PRIMARY KEY (`id`) +) +ENGINE=InnoDB +DEFAULT CHARACTER SET=utf8 COLLATE=utf8_general_ci +COMMENT='产品价格扩展' +AUTO_INCREMENT=1 +ROW_FORMAT=COMPACT +; + +-- ---------------------------- +-- 给单据明细表增加商品扩展id +-- 时间 2020-02-16 +-- by jishenghua +-- ---------------------------- +alter table jsh_depotitem add material_extend_id bigint(20) DEFAULT NULL COMMENT '商品扩展id' after MaterialId; \ No newline at end of file diff --git a/erp_web/css/common.css b/erp_web/css/common.css index 11502f25..39d98f14 100644 --- a/erp_web/css/common.css +++ b/erp_web/css/common.css @@ -4,7 +4,7 @@ } .easyui-dialog .fitem label{ - width:60px; + width:80px; float:left; padding:5px; } diff --git a/erp_web/js/common/common.js b/erp_web/js/common/common.js index e4f53665..53fa5adc 100644 --- a/erp_web/js/common/common.js +++ b/erp_web/js/common/common.js @@ -23,6 +23,31 @@ return o; }; + /** + * 扩展datagrid的editors方法,支持combogrid + */ + $.extend($.fn.datagrid.defaults.editors, { + combogrid: { + init: function (container, options) { + var input = $('').appendTo(container); + input.combogrid(options); + return input; + }, + destroy: function (target) { + $(target).combogrid('destroy'); + }, + getValue: function (target) { + return $(target).combogrid('getValue'); + }, + setValue: function (target, value) { + $(target).combogrid('setValue', value); + }, + resize: function (target, width) { + $(target).combogrid('resize', width); + } + } + }); + $(function() { domresize(); }); diff --git a/erp_web/js/pages/materials/in_out.js b/erp_web/js/pages/materials/in_out.js index 195c4f03..da358910 100644 --- a/erp_web/js/pages/materials/in_out.js +++ b/erp_web/js/pages/materials/in_out.js @@ -533,23 +533,25 @@ dgResize(); } //查找库存的方法 - function findStockNumById(depotId, mId, monthTime, body, input, ratio, type){ + function findStockNumById(depotId, meId, monthTime, body, input, ratio, type){ var thisRatio = 1; //比例 $.ajax({ - url: "/material/findById", + url: "/material/findByIdWithBarCode", type: "get", dataType: "json", data: { - id: mId + meId: meId }, success: function (rec) { - if(rec && rec.code === 200 && rec.data && rec.data[0]) { + if(rec && rec.code === 200) { + var info = rec.data; + var commodityUnit = info.commodityUnit; //商品单位 var loadRatio = 1; //在单位输入框上面加载比例字段 - if(rec.data[0].unit) { //如果存在计量单位信息 + if(info.unit) { //如果存在计量单位信息 loadRatio = 1; } else{ - var unitName = rec.data[0].unitName; + var unitName = info.unitName; if(unitName) { thisRatio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); unitName = unitName.substring(0, unitName.indexOf("(")); @@ -557,24 +559,11 @@ var unitArr = unitName.split(","); var basicUnit = unitArr[0]; //基础单位 var otherUnit = unitArr[1]; //副单位 - var unitSetInput =""; //单位 - if(listSubType === "采购订单" || listSubType === "采购" || listSubType === "采购退货"){ - unitSetInput = rec.data[0].firstinunit; - if(basicUnit==unitSetInput){ //基础单位等于选择的单位 - loadRatio = 1; - } - else if(otherUnit==unitSetInput){ //副单位等于选择的单位 - loadRatio = thisRatio; - } + if(basicUnit==commodityUnit){ //基础单位等于选择的单位 + loadRatio = 1; } - else if(listSubType === "销售订单" || listSubType === "销售" || listSubType === "销售退货" || listSubType === "零售" || listSubType === "零售退货"){ - unitSetInput = rec.data[0].firstoutunit; - if(basicUnit==unitSetInput){ //基础单位等于选择的单位 - loadRatio = 1; - } - else if(otherUnit==unitSetInput){ //副单位等于选择的单位 - loadRatio = thisRatio; - } + else if(otherUnit==commodityUnit){ //副单位等于选择的单位 + loadRatio = thisRatio; } } //查询库存 @@ -583,7 +572,7 @@ url: '/depotItem/findStockNumById', data:{ depotId: depotId, - mId: mId + mId: info.id }, dataType: "json", success: function (res) { @@ -721,7 +710,7 @@ body =$("#depotHeadFM .datagrid-body"); footer =$("#depotHeadFM .datagrid-footer"); input = ".datagrid-editable-input"; - var mId = body.find("[field='MaterialId']").find(".combo-value").val(); + var mId = body.find("[field='MaterialExtendId']").find(".combo-value").val(); if(mId){ var type = "select"; //type 类型:点击 click,选择 select findStockNumById(depotId, mId, monthTime, body, input, ratioDepot, type); @@ -730,37 +719,71 @@ } } }, - { title: '品名(型号)(扩展信息)(单位)',field: 'MaterialId',width:230, + { title: '条码_品名(规格)(型号)(扩展信息)(单位)',field: 'MaterialExtendId',width:270, formatter:function(value,row,index){ return row.MaterialName; }, editor:{ - type:'combobox', - options:{ - valueField:'Id', - textField:'MaterialName', - method:'get', - url: "/material/findBySelect", - panelWidth: 300, //下拉框的宽度 - //全面模糊匹配,过滤字段 - filter: function(q, row){ - var opts = $(this).combobox('options'); - return row[opts.textField].indexOf(q) >-1; - }, + type:'combogrid', + options:{ + url: "/material/findBySelect", + idField:'Id', + textField:'MaterialName', + method:'get', + pagination: true, + mode: 'remote', + hasDownArrow: false, + panelWidth: 630, //下拉框的宽度 + panelHeight: 380,//下拉框的高度 + columns:[[ + {field:'mBarCode',title:'条码',width:120}, + {field:'name',title:'品名',width:140}, + {field:'standard',title:'规格',width:80}, + {field:'model',title:'型号',width:80}, + {field:'unit',title:'单位',width:60}, + {field:'stock',title:'库存',width:50}, + {field:'expand',title:'扩展信息',width:80} + ]], onBeforeLoad: function(param){ + var edDepot = $('#materialData').datagrid('getEditor', {index:editIndex,field:'DepotId'}); + if(edDepot) { + param.depotId = $(edDepot.target).combobox('getValue'); + } param.mpList = mPropertyList; //商品属性 }, - onSelect:function(rec){ - var materialId = $("#depotHeadFM .datagrid-body") - .find("[field='MaterialId']").find(".datagrid-editable-input").val(); - if(materialId !=rec.Id) { - materialSelect(rec); + onLoadSuccess: function (rec) { + if(rec && rec.total==1) { + $(".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){ + // var materialExtendId = $("#depotHeadFM .datagrid-body") + // .find("[field='MaterialExtendId']").find(".datagrid-editable-input").val(); + // if(materialExtendId !=rowData.Id) { + materialSelect(rowData); + // } } - } + } } }, - { title: '库存',field: 'Stock',editor:'validatebox',width:70}, + { title: '库存',field: 'Stock',editor:'validatebox',width:50}, { title: anotherDepotHeadName, field: 'AnotherDepotId',editor:'validatebox',hidden:isShowAnotherDepot,width:90, formatter: function (value, row, index) { return row.AnotherDepotName; @@ -783,12 +806,7 @@ { title: '税率(%)',field: 'TaxRate',editor:'validatebox',hidden:isShowTaxColumn,width:75}, { title: '税额',field: 'TaxMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75}, { title: '价税合计',field: 'TaxLastMoney',editor:'validatebox',hidden:isShowTaxColumn,width:75}, - { title: '备注',field: 'Remark',editor:'validatebox',width:120}, - { title: '品名-别',field: 'OtherField1',editor:'validatebox',hidden:otherColumns,width:60}, - { title: '型号-别',field: 'OtherField2',editor:'validatebox',hidden:otherColumns,width:60}, - { title: '颜色-别',field: 'OtherField3',editor:'validatebox',hidden:otherColumns,width:60}, - { title: '备注1',field: 'OtherField4',editor:'validatebox',hidden:true,width:60}, - { title: '备注2',field: 'OtherField5',editor:'validatebox',hidden:true,width:60} + { title: '备注',field: 'Remark',editor:'validatebox',width:100} ]], toolbar:[ { @@ -885,54 +903,33 @@ function materialSelect(rec) { var body,footer,input; //定义表格和文本框 var ratio = 1; //比例-品名专用 + var loadRatio = 1; //在单位输入框上面加载比例字段 if(rec) { - var mId = rec.Id; + var meId = rec.Id; $.ajax({ - url: "/material/findById", + url: "/material/findByIdWithBarCode", type: "get", dataType: "json", data: { - id: mId + meId: meId }, success: function (res) { - if(res && res.code === 200 && res.data && res.data[0]) { - var retailPrice = res.data[0].retailprice-0; //零售价格 - var presetPriceOne = res.data[0].presetpriceone-0; //预计采购价 - var presetPriceTwo = res.data[0].presetpricetwo-0; //批发价 - var firstInUnit = res.data[0].firstinunit; //首选入库单位 - var firstOutUnit = res.data[0].firstoutunit; //首选出库单位 - var basicPresetPriceOne = ""; //多单位-入库-基础价格 - var basicPresetPriceTwo = ""; //多单位-出库-基础价格 - var retailPriceOne = ""; //多单位-入库-零售价格 - var otherPresetPriceOne = ""; //多单位-入库-其他价格 - var otherPresetPriceTwo = ""; //多单位-出库-其他价格 - var retailPriceTwo = ""; //多单位-出库-零售价格 - var basicUnit = ""; //基础单位 - var otherUnit = ""; //其他单位 - if(!res.data[0].unit){ - var ps = res.data[0].pricestrategy; - var psObj = JSON.parse(ps); - basicPresetPriceOne = psObj[0].basic.PresetPriceOne-0; - basicPresetPriceTwo = psObj[0].basic.PresetPriceTwo-0; - retailPriceOne = psObj[0].basic.RetailPrice-0; - otherPresetPriceOne = psObj[1].other.PresetPriceOne-0; - otherPresetPriceTwo = psObj[1].other.PresetPriceTwo-0; - retailPriceTwo = psObj[1].other.RetailPrice-0; - basicUnit = psObj[0].basic.Unit; - otherUnit = psObj[1].other.Unit; - } - body =$("#depotHeadFM .datagrid-body"); - footer =$("#depotHeadFM .datagrid-footer"); - input = ".datagrid-editable-input"; - if(res.data[0].unit){ //如果存在计量单位信息 - ratio = 1; //重置比例为1 - body.find("[field='Unit']").find(input).val(res.data[0].unit); //设置-计量单位信息 - body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读 - body.find("[field='Unit']").find(input).off("click"); //移除点击事件 - body.find("[field='Unit']").find(input).attr("data-ratio",ratio); //修改比例缓存信息 - } + if(res && res.code === 200) { + var info = res.data; + var commodityDecimal = info.commodityDecimal-0; //零售价 + var purchaseDecimal = info.purchaseDecimal-0; //采购价 + var commodityUnit = info.commodityUnit; //商品单位 + body =$("#depotHeadFM .datagrid-body"); + footer =$("#depotHeadFM .datagrid-footer"); + input = ".datagrid-editable-input"; + body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读 + body.find("[field='Unit']").find(input).val(commodityUnit); //设置单位 + if(info.unit){ //如果存在计量单位信息 + ratio = 1; //重置比例为1 + loadRatio = ratio; + } else { - var unitName = res.data[0].unitName; + var unitName = info.unitName; if(unitName) { ratio = unitName.substring(unitName.indexOf(":")+1).replace(")",""); //给比例赋值 unitName = unitName.substring(0, unitName.indexOf("(")); @@ -940,146 +937,29 @@ var unitArr = unitName.split(","); var basicUnit = unitArr[0]; //基础单位 var otherUnit = unitArr[1]; //副单位 - var unitSetInput =""; //单位 - body.find("[field='Unit']").find(input).prop("readonly","readonly"); //设置计量单位为只读 - var loadRatio = 1; //在单位输入框上面加载比例字段 - if(listSubType === "采购" || listSubType === "采购退货" || listSubType === "采购订单"){ - unitSetInput = res.data[0].firstinunit; //给单位文本框赋值 - if(basicUnit==unitSetInput){ //基础单位等于选择的单位 - loadRatio = 1; - } - else if(otherUnit==unitSetInput){ //副单位等于选择的单位 - loadRatio = ratio; - } - } - else if(listSubType === "销售" || listSubType === "销售退货" || listSubType === "销售订单" || listSubType === "零售" || listSubType === "零售退货"){ - unitSetInput = res.data[0].firstoutunit; //给单位文本框赋值 - if(basicUnit==unitSetInput){ //基础单位等于选择的单位 - loadRatio = 1; - } - else if(otherUnit==unitSetInput){ //副单位等于选择的单位 - loadRatio = ratio; - } - } - body.find("[field='Unit']").find(input).val(unitSetInput).attr("data-ratio", loadRatio); //设置-首选单位 - - body.find("[field='Unit']").find(input).off("click").on("click",function(){ - if(basicUnit && otherUnit) { - var self = this; - //定义模版 - var temp = "