|
|
@@ -0,0 +1,240 @@
|
|
|
+Ext.QuickTips.init();
|
|
|
+Ext.define('erp.controller.pm.mes.MakeSNRuleMain', {
|
|
|
+ extend : 'Ext.app.Controller',
|
|
|
+ FormUtil : Ext.create('erp.util.FormUtil'),
|
|
|
+ GridUtil : Ext.create('erp.util.GridUtil'),
|
|
|
+ BaseUtil : Ext.create('erp.util.BaseUtil'),
|
|
|
+ views : [ 'pm.mes.MakeSNRuleMain', 'core.form.Panel',
|
|
|
+ 'core.toolbar.Toolbar', 'core.button.Close', 'core.trigger.DbfindTrigger',
|
|
|
+ 'core.trigger.TextAreaTrigger', 'core.trigger.MultiDbfindTrigger','core.button.Delete',
|
|
|
+ 'core.form.YnField','core.button.DeleteAllDetails',
|
|
|
+ 'core.button.GenerateBarcode','core.button.SuppleGenBar'],
|
|
|
+ init : function() {
|
|
|
+ var me = this;
|
|
|
+ this.control({
|
|
|
+ '#mm_id':{
|
|
|
+ afterrender:function(field){
|
|
|
+ if(field.value != null && field.value != ''&&field.value != 0){
|
|
|
+ var macode = Ext.getCmp('mm_macode')
|
|
|
+ macode.setReadOnly(true);
|
|
|
+ macode.editable = false;
|
|
|
+ if(macode.xtype == 'dbfindtrigger'){
|
|
|
+ macode.setHideTrigger(true);
|
|
|
+ }
|
|
|
+ macode.fieldStyle = 'background:#EEEEEE';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成条码
|
|
|
+ */
|
|
|
+ 'erpGenerateBarcodeButton':{
|
|
|
+ click : function(btn){
|
|
|
+ var form = Ext.getCmp('form');
|
|
|
+ if(! me.FormUtil.checkForm()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //判断本次数量必填
|
|
|
+ var thisqty = Ext.getCmp("mm_thisqty");
|
|
|
+ if(!thisqty){
|
|
|
+ showError("必须配置并且维护本次数量字段!")
|
|
|
+ }
|
|
|
+ if(thisqty && (thisqty.value == null || thisqty.value == '' || thisqty.value<=0)){
|
|
|
+ showError("本次数量必须大于0,并且是整数!")
|
|
|
+ }
|
|
|
+
|
|
|
+ if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
|
|
|
+ me.BaseUtil.getRandomNumber();//自动添加编号
|
|
|
+ }
|
|
|
+ if(form.keyField){ //获取ID
|
|
|
+ if(Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == ''){
|
|
|
+ me.FormUtil.getSeqId(form);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(form.getForm().isValid()){
|
|
|
+ Ext.each(form.items.items, function(item){
|
|
|
+ if(item.xtype == 'numberfield'){
|
|
|
+ if(item.value == null || item.value == ''){
|
|
|
+ item.setValue(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var r = form.getValues();
|
|
|
+ //去除ignore字段
|
|
|
+ var keys = Ext.Object.getKeys(r), f;
|
|
|
+ var reg = /[!@#$%^&*()'":,\/?]/;
|
|
|
+ Ext.each(keys, function(k){
|
|
|
+ f = form.down('#' + k);
|
|
|
+ if(f && f.logic == 'ignore') {
|
|
|
+ delete r[k];
|
|
|
+ }
|
|
|
+ //codeField值强制大写,自动过滤特殊字符
|
|
|
+ if(k == form.codeField && !Ext.isEmpty(r[k])) {
|
|
|
+ r[k] = r[k].trim().toUpperCase().replace(reg, '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ me.save(r, '/pm/mes/genSNRuleDetail.action',form);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 补生成条码
|
|
|
+ */
|
|
|
+ 'erpSuppleGenBarButton': {
|
|
|
+ click: function (btn) {
|
|
|
+ var form = Ext.getCmp('form');
|
|
|
+ if (!me.FormUtil.checkForm()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //判断本次数量必填
|
|
|
+ var addqty = Ext.getCmp("mm_addqty");
|
|
|
+ if (!addqty) {
|
|
|
+ showError("必须配置并且维护补生成数量字段!")
|
|
|
+ }
|
|
|
+ if (addqty && (addqty.value == null || addqty.value == '' || addqty.value <= 0)) {
|
|
|
+ showError("补生成数量必须大于0,并且是整数!")
|
|
|
+ }
|
|
|
+ if (Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == '') {
|
|
|
+ me.BaseUtil.getRandomNumber();//自动添加编号
|
|
|
+ }
|
|
|
+ if (form.keyField && (Ext.getCmp(form.keyField).value == null || Ext.getCmp(form.keyField).value == '')) {
|
|
|
+ me.FormUtil.getSeqId(form);
|
|
|
+ }
|
|
|
+ if (form.getForm().isValid()) {
|
|
|
+ Ext.each(form.items.items, function (item) {
|
|
|
+ if (item.xtype == 'numberfield') {
|
|
|
+ if (item.value == null || item.value == '') {
|
|
|
+ item.setValue(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ var r = form.getValues();
|
|
|
+ //去除ignore字段
|
|
|
+ var keys = Ext.Object.getKeys(r), f;
|
|
|
+ var reg = /[!@#$%^&*()'":,\/?]/;
|
|
|
+ Ext.each(keys, function (k) {
|
|
|
+ f = form.down('#' + k);
|
|
|
+ if (f && f.logic == 'ignore') {
|
|
|
+ delete r[k];
|
|
|
+ }
|
|
|
+ //codeField值强制大写,自动过滤特殊字符
|
|
|
+ if (k == form.codeField && !Ext.isEmpty(r[k])) {
|
|
|
+ r[k] = r[k].trim().toUpperCase().replace(reg, '');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ me.save(r, '/pm/mes/suppleSNRuleDetail.action', form);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ //删除全部条码明细
|
|
|
+ 'erpDeleteAllDetailsButton':{
|
|
|
+ afterrender:function(btn){
|
|
|
+ var v_mid = Ext.getCmp("mm_id");
|
|
|
+ if(v_mid && (v_mid.value==0 ||null == v_mid.value ||'' == v_mid.value)){
|
|
|
+ btn.hide();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ click:function (btn){
|
|
|
+ warnMsg("确定清空所有条码明细", function(btn){
|
|
|
+ if(btn == 'yes'){
|
|
|
+ Ext.Ajax.request({
|
|
|
+ url : basePath + "pm/mes/deleteSNRuleDetail.action",
|
|
|
+ params: {
|
|
|
+ caller: caller,
|
|
|
+ id:Ext.getCmp("mm_id").value
|
|
|
+ },
|
|
|
+ method : 'post',
|
|
|
+ callback : function(options,success,response){
|
|
|
+ var res = new Ext.decode(response.responseText);
|
|
|
+ if(res.exceptionInfo != null){
|
|
|
+ showError(res.exceptionInfo);return;
|
|
|
+ }else {
|
|
|
+ window.location.href = window.location.href;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'erpCloseButton' : {
|
|
|
+ click : function(btn) {
|
|
|
+ me.FormUtil.beforeClose(me);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 'erpDeleteButton':{
|
|
|
+ click: function(btn){
|
|
|
+ me.FormUtil.onDelete(Ext.getCmp('mm_id').value);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ getForm : function(btn) {
|
|
|
+ return btn.ownerCt.ownerCt;
|
|
|
+ },
|
|
|
+
|
|
|
+ save: function(r,url,form){
|
|
|
+ var me = this;
|
|
|
+ var params = new Object();
|
|
|
+ Ext.each(Ext.Object.getKeys(r), function(k){//去掉页面非表单定义字段
|
|
|
+ if(contains(k, 'ext-', true)){
|
|
|
+ delete r[k];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ params.formStore = unescape(escape(Ext.JSON.encode(r)));
|
|
|
+ params.caller = caller;
|
|
|
+ form.setLoading(true);
|
|
|
+ Ext.Ajax.request({
|
|
|
+ url : basePath + url,
|
|
|
+ params : params,
|
|
|
+ method : 'post',
|
|
|
+ callback : function(options,success,response){
|
|
|
+ form.setLoading(false);
|
|
|
+ var localJson = new Ext.decode(response.responseText);
|
|
|
+ if(localJson.success){
|
|
|
+ showMessage('提示', '生成条码成功!', 1000);
|
|
|
+ //update成功后刷新页面进入可编辑的页面
|
|
|
+ var u = String(window.location.href);
|
|
|
+ if (u.indexOf('formCondition') == -1) {
|
|
|
+ var value = r[form.keyField];
|
|
|
+ var formCondition = form.keyField + "IS" + value ;
|
|
|
+ if(me.contains(window.location.href, '?', true)){
|
|
|
+ window.location.href = window.location.href + '&formCondition=' + formCondition ;
|
|
|
+ } else {
|
|
|
+ window.location.href = window.location.href + '?formCondition=' + formCondition ;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ window.location.reload();
|
|
|
+ }
|
|
|
+ } else if(localJson.exceptionInfo){
|
|
|
+ var str = localJson.exceptionInfo;
|
|
|
+ if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
|
|
|
+ str = str.replace('AFTERSUCCESS', '');
|
|
|
+ //update成功后刷新页面进入可编辑的页面
|
|
|
+ var u = String(window.location.href);
|
|
|
+ if (u.indexOf('formCondition') == -1) {
|
|
|
+ var value = r[form.keyField];
|
|
|
+ var formCondition = form.keyField + "IS" + value ;
|
|
|
+ if(me.contains(window.location.href, '?', true)){
|
|
|
+ window.location.href = window.location.href + '&formCondition=' + formCondition ;
|
|
|
+ } else {
|
|
|
+ window.location.href = window.location.href + '?formCondition=' + formCondition ;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ window.location.reload();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ showError(str);return;
|
|
|
+ } else{
|
|
|
+ saveFailure();//@i18n/i18n.js
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+});
|