Browse Source

[微浦MES]物料替代料新增独立维护界面
(cherry picked from commit 6fe5ff0)

caosy 5 years ago
parent
commit
b30424e37b

+ 85 - 0
WebContent/app/controller/scm/product/ProductRelation.js

@@ -0,0 +1,85 @@
+Ext.QuickTips.init();
+Ext.define('erp.controller.scm.product.ProductRelation', {
+    extend: 'Ext.app.Controller',
+    FormUtil: Ext.create('erp.util.FormUtil'),
+    BaseUtil: Ext.create('erp.util.BaseUtil'),
+    GridUtil: Ext.create('erp.util.GridUtil'),
+    views:[
+    		'scm.product.ProductRelation','core.form.Panel','core.button.Add','core.button.Save','core.button.Close',
+    		'core.button.Update','core.button.CleanDetail','core.form.YnField','core.grid.YnColumn','core.button.Flow',
+    		'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.MultiField','core.grid.Panel2'
+    	  ],
+    init:function(){
+    	var me = this;
+    	this.control({
+    		'erpFormPanel': {
+				afterload: function(form) {
+					var items = form.items.items;
+					Ext.each(items, function(item) {
+						item.setReadOnly(true);
+					});
+				}
+			},
+			'erpGridPanel2': { 
+    			itemclick: function(view,record){
+    				me.itemclick(view,record,me);
+    			}
+    		},
+    		'erpSaveButton': {
+    			click: function(btn){
+    				this.FormUtil.beforeSave(this);   				
+    			}
+    		},
+    		'erpCloseButton': {
+    			click: function(btn){
+    				this.FormUtil.beforeClose(this);
+    			}
+    		},
+    		'erpUpdateButton': {
+    			afterrender: function(btn){
+    				if(Ext.getCmp('bd_id').value == null || Ext.getCmp('bd_id').value == ''){
+    					btn.hide();
+    				}
+    			},
+    			click: function(btn){
+    				this.FormUtil.onUpdate(this);
+    			}
+    		},
+    		'erpCleanDetailButton': {
+    			afterrender: function(btn){
+    				if(Ext.getCmp('bd_id').value == null || Ext.getCmp('bd_id').value == ''){
+    					btn.hide();
+    				}
+    			},
+    			click: function(btn){ 
+    				var bd_id = Ext.getCmp('bd_id');
+    				Ext.Ajax.request({
+    					url: basePath + 'scm/product/deleteProductRelation.action',
+    					params: {
+    						id: Ext.getCmp('bd_id').value,
+    						pr_code: bd_id.value,
+    						caller: caller
+    					},
+    					callback: function(opt, s, r) {
+    						var rs = Ext.decode(r.responseText);
+    						if(rs.exceptionInfo) {
+    							showError(rs.exceptionInfo);return;
+    						} else {
+    							var grid = Ext.getCmp('grid');
+    							Ext.Msg.alert("提示", "清除明细成功!", function(){
+    								me.GridUtil.loadNewStore(grid, {
+        								caller: caller,
+        								condition: "prr_bdid='"+bd_id.value+"'"
+        							});
+    			   				});
+    						}
+    					}
+    				});  
+    			}
+    		}
+    	});
+    },
+    itemclick:function(view,record,me){
+    	me.GridUtil.onGridItemClick(view,record); 
+    }
+});

+ 30 - 0
WebContent/app/view/scm/product/ProductRelation.js

@@ -0,0 +1,30 @@
+Ext.define('erp.view.scm.product.ProductRelation',{
+	extend: 'Ext.Viewport', 
+	layout: 'fit', 
+	hideBorders: true, 
+	initComponent : function(){ 
+		var me = this; 
+		Ext.apply(me, { 
+			items: [{ 
+				layout: 'anchor',
+				bodyStyle: 'background:#f1f1f1;',
+				items: [{
+					xtype: 'erpFormPanel',
+					anchor: '100% 20%',
+					saveUrl: 'scm/product/saveProductRelation.action',
+					deleteUrl: 'scm/product/deleteProductRelation.action',
+					updateUrl: 'scm/product/updateProductRelation.action',
+					getIdUrl: 'common/getId.action?seq=PRODUCTRELATION_SEQ',
+					keyField: 'bd_id'
+				},{
+					xtype: 'erpGridPanel2',
+					anchor: '100% 80%',
+					detno : 'prr_detno',
+					keyField : 'prr_id',
+					mainField : 'prr_bdid'
+				}]
+			}] 
+		}); 
+		me.callParent(arguments); 
+	} 
+});

+ 36 - 0
WebContent/jsps/scm/product/productRelation.jsp

@@ -0,0 +1,36 @@
+<%@ page language="java" contentType="text/html; charset=utf-8"
+    pageEncoding="utf-8"%>
+<%
+String path = request.getContextPath();
+String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
+%>
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link rel="stylesheet" href="<%=basePath %>resource/ext/resources/css/ext-all-gray.css" type="text/css"></link>
+<link rel="stylesheet" href="<%=basePath %>resource/css/main.css" type="text/css"></link>
+<script type="text/javascript" src="<%=basePath %>resource/ext/ext-all.js"></script>
+<script type="text/javascript" src="<%=basePath %>resource/i18n/i18n.js"></script>
+<script type="text/javascript">	
+Ext.Loader.setConfig({
+	enabled: true
+});//开启动态加载
+Ext.application({
+    name: 'erp',//为应用程序起一个名字,相当于命名空间
+    appFolder: basePath+'app',//app文件夹所在路径
+    controllers: [//声明所用到的控制层
+        'scm.product.ProductRelation'
+    ],
+    launch: function() {
+    	Ext.create('erp.view.scm.product.ProductRelation');//创建视图
+    }
+});
+var caller ="ProductRelation";
+var formCondition = '';
+var gridCondition = '';
+</script>
+</head>
+<body >
+</body>
+</html>

+ 49 - 0
src/com/uas/mes/scm/controller/ProductRelationController.java

@@ -0,0 +1,49 @@
+package com.uas.mes.scm.controller;
+
+import com.uas.mes.core.util.BaseController;
+import com.uas.mes.scm.service.ProductRelationService;
+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 java.util.HashMap;
+import java.util.Map;
+
+
+@Controller
+public class ProductRelationController extends BaseController {
+	@Autowired
+	private ProductRelationService productRelationService;
+
+	/**
+	 * 删除
+	 */
+	@RequestMapping("/scm/product/deleteProductRelation.action")
+	@ResponseBody
+	public Map<String, Object> deleteProductRule(int id, String caller, String pr_code) {
+		Map<String, Object> modelMap = new HashMap<String, Object>();
+		productRelationService.deleteProductRelation(id, caller, pr_code);
+		modelMap.put("success", true);
+		return modelMap;
+	}
+
+	/**
+	 * 修改form和grid数据
+	 * 
+	 * @param formStore
+	 *            form数据
+	 * @param param
+	 *            grid数据
+	 */
+	@RequestMapping("/scm/product/updateProductRelation.action")
+	@ResponseBody
+	public Map<String, Object> update(String caller, String formStore,
+			String param) {
+		Map<String, Object> modelMap = new HashMap<String, Object>();
+		productRelationService.updateProductRelationById(caller, formStore, param);
+		modelMap.put("success", true);
+		return modelMap;
+	}
+
+}

+ 6 - 0
src/com/uas/mes/scm/service/ProductRelationService.java

@@ -0,0 +1,6 @@
+package com.uas.mes.scm.service;
+
+public interface ProductRelationService {
+	void updateProductRelationById(String caller, String formStore, String gridStore);
+	void deleteProductRelation(int id, String caller, String pr_code);
+}

+ 50 - 0
src/com/uas/mes/scm/service/impl/ProductRelationServiceImpl.java

@@ -0,0 +1,50 @@
+package com.uas.mes.scm.service.impl;
+
+import com.uas.mes.common.data.BaseDao;
+import com.uas.mes.common.data.SqlUtil;
+import com.uas.mes.common.support.HandlerService;
+import com.uas.mes.common.util.BaseUtil;
+import com.uas.mes.core.util.FlexJsonUtil;
+import com.uas.mes.scm.service.ProductRelationService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+@Service
+public class ProductRelationServiceImpl implements ProductRelationService {
+	@Autowired
+	private BaseDao baseDao;
+	@Autowired
+	private HandlerService handlerService;
+
+	@Override
+	public void updateProductRelationById(String caller, String formStore, String gridStore) {
+		Map<Object, Object> store = BaseUtil.parseFormStoreToMap(formStore); //将form转换成Map格式的
+		List<Map<Object, Object>> gstore = FlexJsonUtil.fromJsonArray(gridStore,HashMap.class);
+		// 执行修改前的其它逻辑
+		handlerService.beforeUpdate(caller, new Object[] { gstore });//因为要判定在它之前所对应的所以必须得写两个参数
+		List<String> gridSql = SqlUtil.getInsertOrUpdateSqlbyGridStore(gstore, "productrelation", "prr_id");
+		String errors = baseDao
+				.executeWithCheck(gridSql, null,
+						"select wm_concat(prr_reprodcode) from (select distinct prr_reprodcode from productrelation where prr_bdid='"+ store.get("bd_id") +"' group by prr_reprodcode having count(1)>1)");
+		if(errors != null && errors != "null")					
+			BaseUtil.showError("替代料号维护重复: " + errors);
+		//日志的记录作用
+		baseDao.logger.update(caller, "pr_code", store.get("bd_soncode"));
+		// 执行修改后的其它逻辑
+		handlerService.afterUpdate(caller, new Object[] { gstore });
+	}
+
+	@Override
+	public void deleteProductRelation(int id, String caller, String pr_code) {
+		baseDao.execute("delete from productrelation where prr_bdid= ?", id);
+		//记录操作
+		baseDao.logger.others("清除明细", "清除明细成功", caller, "pr_code", pr_code);
+	}
+
+
+}