| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.make.MakeMaterial', {
- extend: 'Ext.app.Controller',
- requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
- views:[
- 'core.form.Panel','pm.make.MakeBase','core.grid.Panel2','core.toolbar.Toolbar','core.form.MultiField','core.form.YnField',
- 'core.button.Save','core.button.MakeDownPut','core.button.Add','core.button.Submit','core.button.ResAudit',
- 'core.button.Audit','core.button.ResMakeDownPut','core.button.Close','core.button.Delete','core.button.Update','core.button.ResSubmit',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.grid.YnColumn','core.button.Flow','core.button.UpdateTeamcode',
- 'core.trigger.MultiDbfindTrigger','core.button.EnforceEnd','core.button.End', 'core.button.ResEnd','core.button.ModifyMaterial',
- 'core.button.SubRelation','core.button.UpdateRemark','erp.view.core.grid.HeaderFilter','core.button.MakeSNCode',
- 'core.button.MakeStop','core.button.MakeResStop','core.button.ModifyDetail','core.button.Modify','core.button.VindicateMake',
- 'core.button.CleanDetail','core.button.UpdateMaterial','core.button.CopyByConfigs','core.button.DecomSetting'],
- init:function(){
- var me = this;
- me.FormUtil = Ext.create('erp.util.FormUtil');
- me.GridUtil = Ext.create('erp.util.GridUtil');
- me.BaseUtil = Ext.create('erp.util.BaseUtil');
- this.control({
- '#ma_remark':{
- beforerender: function(field){
- field.readOnly=false;
- }
- },
- '#ma_teamcode':{
- beforerender: function(field){
- field.readOnly=false;
- }
- },
- '#ma_style':{
- beforerender: function(field){
- field.readOnly=false;
- }
- },
- 'erpGridPanel2': {
- afterrender: function(grid){
- var status = Ext.getCmp('ma_statuscode');
- if(status && status.value != 'ENTERING' ){
- grid.setReadOnly(true);
- }
- },
- reconfigure:function(grid){
- var items = grid.store.data.items;
- var totaluseqty = grid.store.getSum(items, 'mm_totaluseqty');
- var havegetqty = grid.store.getSum(items, 'mm_havegetqty');
- if( totaluseqty!=0 || havegetqty!=0){
- }
- },
- itemclick: function(view,record){
- me.itemclick(view,record,me);
- }
- },
- 'field[name=ma_currency]': {
- beforetrigger: function(field) {
- var value = Ext.getCmp('ma_date').value;
- if(value) {
- field.findConfig = 'cm_yearmonth=' + Ext.Date.format(value, 'Ym');
- }
- }
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn), codeField = Ext.getCmp(form.codeField);
- if(codeField.value == null || codeField.value == ''){
- me.BaseUtil.getRandomNumber(caller);//自动添加编号
- var res = me.getLeadCode(Ext.getCmp('ma_kind').value);
- if(res != null && res != ''){
- codeField.setValue(res + codeField.getValue());
- }
- }
- console.log(123456);
- this.FormUtil.beforeSave(this);
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- this.FormUtil.beforeClose(this);
- }
- },
- 'erpCleanDetailButton':{
- click: function(btn){
- me.cleanDetail();
- }
- },
- 'erpUpdateMaterialButton': {
- click: function(btn){
- this.FormUtil.onUpdate(this);
- }
- },
- 'erpDecomSettingButton':{
- afterrender: function(btn){
- var ma_kind = Ext.getCmp("ma_kind");
- if(ma_kind && ma_kind.value != '返工' ){
- btn.hide();
- }
- },
- click: function(btn){
- var ma_screcode = Ext.getCmp('ma_screcode').value;
- var grid = Ext.getCmp('grid');
- var caller = 'DecomSetting!Make';
- var id = Ext.getCmp('ma_id').value;
- var result = 0;
- if(ma_screcode != null && ma_screcode !=''){
- Ext.Ajax.request({
- url : basePath + 'common/getFieldData.action',
- async: false,
- params: {
- caller: 'reworkdetail left join rework on re_id = rd_reid',
- field: 'count(rd_sncode)',
- condition: "re_code= '" + ma_screcode +"'"
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);return;
- } else if(r.success){
- result = r.data;
- }
- }
- });
- }else{
- showError("返工需求单号为空");return;
- }
- if(result > 0){
- var dbwin = new Ext.window.Window({
- id : 'dcswin',
- title: '拆解部件设定',
- height: "100%",
- width: "80%",
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items: [],
- listeners:{
- beforeclose: function(){
- window.location.reload();
- }
- }
- });
- dbwin.add({
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_DecomSetting!Make" src="'+basePath+'jsps/pm/make/decomSetting.jsp?whoami='+caller+'&formCondition=ma_idIS'+id+'&gridCondition=mm_maidIS'+id+'" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>'
- });
- dbwin.show();
- }else{
- showError("不存在序列号");return;
- }
- /*var items = grid.getStore().data.items;//获取store里面的数据
- */
-
- }
- },
- 'dbfindtrigger[name=ma_saledetno]': {
- afterrender: function(t){
- t.dbKey = "ma_salecode";
- t.mappingKey = "sd_code";
- t.dbMessage = "请先选择订单编号!";
- }
- },
- 'combo[name=ma_sourcekind]':{
- change:function(field,newValue){
- var codefield=Ext.getCmp('ma_salecode');
- var detnofield=Ext.getCmp('ma_saledetno');
- if(newValue=='Sale'){
- //销售预测
- codefield.dbCaller='Make!Base';
- detnofield.dbCaller='Make!Base';
- }else if(newValue=='SaleForeCast'){
- codefield.dbCaller='Make!Base!ForeCast';
- detnofield.dbCaller='Make!Base!ForeCast';
-
- }
- }
- },
- 'dbfindtrigger[name=mm_prodcode]': {
- },
- 'textfield[name=ma_wccode]': {
- change: function(field){
- if(field.value != null && field.value != ''){
- var grid = Ext.getCmp('grid');
- var d = field.value;
- Ext.Array.each(grid.getStore().data.items,function(item){
- if(item.data['mm_prodcode'] != null && item.data['mm_prodcode'] != '' ){
- if(item.data['mm_wccode'] == null ||item.data['mm_wccode'] == '' ){
- item.set('mm_wccode',d);
- }
- }
- });
- }
- }
- },
- 'datefield[name=ma_planenddate]':{
- change: function(f) {
- var c = Ext.getCmp('ma_planbegindate').getValue();
- var value = f.value;
- if( c != null && c != '' && value !=null && value != ''){
- if(c > value){
- Ext.getCmp('ma_planbegindate').setValue('');
- showError('计划完工日期不能早于计划开工日期');
- }
- }
- }
- },
- 'datefield[name=ma_planbegindate]':{
- change: function(f) {
- var c = Ext.getCmp('ma_planenddate').getValue();
- var value = f.value;
- if( value !=null && value != ''){
- var formatV = new Date(Ext.util.Format.date(value, 'Y-m-d'));
- if(c != null && c != '' ){
- if(value > c){
- Ext.getCmp('ma_planenddate').setValue('');
- showError('计划完工日期不能早于计划开工日期');
- }
- }
- }
- }
- },
- 'field[name=ma_prodcode]': {
- change: function(f){
- if(f.value != null && f.value != ''){
- me.FormUtil.getFieldValue('BOM', 'bo_id', "bo_mothercode='" + f.value + "'", 'ma_bomid');
- }
- }
- },
- 'field[name=ma_remark]': {
- beforerender: function(t){
- if(Ext.getCmp('ma_remark')){
- Ext.getCmp('ma_remark').setReadOnly(true);
- }
- }
- },
- 'field[name=ma_price]': {
- change: function(f){
- if(f.value == null || f.value == ''){
- f.value = 0;
- }
- if(Ext.getCmp('ma_total')){//字段存在赋值,不存在不赋值
- Ext.getCmp('ma_total').setValue(f.value*Ext.getCmp('ma_qty').value);
- }
- }
- },
- 'field[name=mm_oneuseqty]': {
- change: function(f){//制单需求=制单套数*单位用量
- if(f.value != null && f.value > 0 && Ext.getCmp('ma_qty') && Ext.getCmp('ma_qty').value > 0){
- var record = Ext.getCmp('grid').selModel.getLastSelected();
- if(record.data['mm_qty'] != f.value*Ext.getCmp('ma_qty').value){
- record.set('mm_qty', f.value*Ext.getCmp('ma_qty').value);
- }
- }
- }
- },
- 'dbfindtrigger[name=ma_craftcode]': {
- beforetrigger: function(field) {
- var t = field.up('form').down('field[name=ma_prodcode]'),
- value = t.getValue();
- if(value) {
- field.findConfig = "cr_prodcode='" + value + "'";
- }
- }
- },
- 'dbfindtrigger[name=ma_bomversion]': {
- beforetrigger: function(field) {
- var value1 = Ext.getCmp('ma_prodcode').value;
- var value2 = Ext.getCmp('ma_craftcode').value;
- if(value1 && value2) {
- field.findConfig = "sb_prodcode='"+value1+"' and sb_craftcode = '"+value2+"'";
- }else if(value1){
- field.findConfig = "sb_prodcode='"+value1+"'";
- }else if(value2){
- field.findConfig = "sb_craftcode = '"+value2+"'";
- }
- }
- }
- });
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- },
- cleanDetail : function() {
- var grid = Ext.getCmp('grid');
- grid.setLoading(true);
- Ext.Ajax.request({
- url : basePath + 'pm/make/cleanMaterial.action',
- params : {
- id : Ext.getCmp('ma_id').value
- },
- method : 'post',
- callback : function(options, success, response) {
- grid.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if (localJson.success) {
- showMessage('提示', '清除成功!', 1000);
- //update成功后刷新页面进入可编辑的页面
- window.location.reload();
- } else if (localJson.exceptionInfo) {
- showError(str);
- return;
- }
- }
- });
- },
- itemclick:function(view,record,me){
- var show=0;
- me.GridUtil.onGridItemClick(view,record);
- var fieldValue=record.data["mm_prodcode"];
- if(fieldValue==undefined||fieldValue==""||fieldValue==null){
- show=1;
- return;
- }
- var status = Ext.getCmp('ma_statuscode').getValue();
- /*if(show==1 || status=='FINISH' ){
- Ext.getCmp('SubRelation').setDisabled(true);
- Ext.getCmp('ModifyMaterial').setDisabled(true);
- }else {
- Ext.getCmp('SubRelation').setDisabled(false);
- Ext.getCmp('ModifyMaterial').setDisabled(false);
- }*/
- },
- getFdValue: function(tablename,field, condition){//根据特征项code和特征值码获取特征值
- var result = '';
- Ext.Ajax.request({
- url : basePath + "/common/getFieldData.action",
- params: {
- caller: tablename,
- field: field,
- condition: condition
- },
- method : 'post',
- async: false,
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- if(res.success){
- result = res.data;
- }
- }
- });
- return result;
- },
- getRandomNumber: function(table, type, codeField){
- if(Ext.getCmp('ma_kind')){
- var form = Ext.getCmp('form');
- if(form){
- table = table == null ? form.tablename : table;
- }
- type = type == null ? 2 : type;
- codeField = codeField == null ? form.codeField : codeField;
- Ext.Ajax.request({
- url : basePath + 'pm/make/getCodeString.action',
- async: false,//同步ajax请求
- params: {
- caller: caller,//如果table==null,则根据caller去form表取对应table
- table: table,
- type: type,
- conKind:Ext.getCmp('ma_kind').getValue()
- },
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- Ext.getCmp(codeField).setValue(localJson.code);
- }
- }
- });
- } else {
- this.BaseUtil.getRandomNumber(caller);//自动添加编号
- }
- },
- getLeadCode: function(type) {
- var result = null;
- Ext.Ajax.request({
- url : basePath + 'common/getFieldData.action',
- async: false,
- params: {
- caller: 'MakeKind',
- field: 'mk_excode',
- condition: 'mk_name=\'' + type + '\''
- },
- method : 'post',
- callback : function(opt, s, res){
- var r = new Ext.decode(res.responseText);
- if(r.exceptionInfo){
- showError(r.exceptionInfo);return;
- } else if(r.success){
- result = r.data;
- }
- }
- });
- return result;
- },
- onEnd : function(id,text){
- var me = this;
- var form = Ext.getCmp('form');
- if(form.endUrl && !me.contains(form.endUrl, '?caller=', true)){
- form.endUrl = form.endUrl + "?caller=" + caller;
- }
- me.setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + form.endUrl,
- params: {
- id: id,
- remark: text
- },
- method : 'post',
- callback : function(options,success,response){
- me.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.success){
- endSuccess(function(){
- window.location.reload();
- });
- } else {
- if(localJson.exceptionInfo){
- var str = localJson.exceptionInfo;
- if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
- str = str.replace('AFTERSUCCESS', '');
- showError(str);
- endSuccess(function(){
- window.location.reload();
- });
- } else {
- showError(str);return;
- }
- }
- }
- }
- });
- },
- /**
- * string:原始字符串
- * substr:子字符串
- * isIgnoreCase:忽略大小写
- */
- contains: function(string, substr, isIgnoreCase){
- if (string == null || substr == null) return false;
- if (isIgnoreCase === undefined || isIgnoreCase === true) {
- string = string.toLowerCase();
- substr = substr.toLowerCase();
- }
- return string.indexOf(substr) > -1;
- },
- setLoading : function(b) {// 原this.getActiveTab().setLoading()换成此方法,解决Window模式下无loading问题
- var mask = this.mask;
- if (!mask) {
- this.mask = mask = new Ext.LoadMask(Ext.getBody(), {
- msg : "处理中,请稍后...",
- msgCls : 'z-index:10000;'
- });
- }
- if (b)
- mask.show();
- else
- mask.hide();
- },
- openTab : function (panel,id){
- var o = (typeof panel == "string" ? panel : id || panel.id);
- var main = parent.Ext.getCmp("content-panel");
- /*var tab = main.getComponent(o); */
- if(!main) {
- main =parent.parent.Ext.getCmp("content-panel");
- }
- var tab = main.getComponent(o);
- if (tab) {
- main.setActiveTab(tab);
- } else if(typeof panel!="string"){
- panel.id = o;
- var p = main.add(panel);
- main.setActiveTab(p);
- }
- }
- });
|