| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.pm.make.MakeSendLS', {
- extend: 'Ext.app.Controller',
- GridUtil: Ext.create('erp.util.GridUtil'),
- requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil', 'erp.util.RenderUtil'],
- views:[
- 'pm.make.MakeSendLS','common.batchDeal.GridPanel','common.batchDeal.Form',
- 'core.form.ConDateField','core.button.Close','core.form.YnField','core.form.MultiField',
- 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.trigger.MultiDbfindTrigger'
- ],
- init:function(){
- var me = this;
- me.GridUtil = Ext.create('erp.util.GridUtil');
- me.BaseUtil = Ext.create('erp.util.BaseUtil');
- this.control({
- 'button[id=query]': {
- click: function(btn){
- var me = this;
- if(Ext.getCmp('ma_code').value ==null||Ext.getCmp('ma_code').value ==''){
- showError('制造单号为空,请填写以后再筛选!');
- return;
- }
- if(Ext.getCmp('ma_xbwhouse').value ==null||Ext.getCmp('ma_xbwhouse').value ==''){
- showError('线边仓库必须填写!');
- return;
- }
- if(Ext.getCmp('setqty').value !=null && Ext.getCmp('setqty').value !='' && Ext.getCmp('setqty').value !='0'){
- if(Ext.getCmp('setqty').value>Ext.getCmp('ma_qty').value-Ext.getCmp('ma_madeqty').value){
- showError('套料数量不能大于未完工数!');
- return;
- }
- }
- var result = me.getId(Ext.getCmp('ma_code').value);
- if (result != null){
- this.onQuery();
- } else{
- return;
- }
- }
- },
- 'erpBatchDealGridPanel' : {
- storeloaded: function(grid) {
- me.getProductWh(grid);
- }
- },
- 'button[id=add]': {
- click: function(btn){
- if(Ext.getCmp('ma_departmentcode').value ==null||Ext.getCmp('ma_departmentcode').value ==''){
- showError('部门编号为空, 请重新填写!');
- return;
- }
- if(Ext.getCmp('ms_recordorcode').value ==null||Ext.getCmp('ms_recordorcode').value ==''){
- showError('人员编号为空, 请重新填写!');
- return;
- }
- var grid = Ext.getCmp('batchDealGridPanel');
- warnMsg("确定要发料吗?", function(btn){
- if(btn == 'yes'){
- me.create(grid);
- }
- });
-
- }
- }
- });
- },
- getProductWh: function(grid) {
- var codes = [];
- grid.store.each(function(d){
- codes.push("'" + d.get('mm_prodcode') + "'");
- });
- if (codes!=[]){
- Ext.Ajax.request({
- url: basePath + 'scm/product/getProductwh.action',
- params: {
- codes: codes.join(',')
- },
- callback: function (opt, s, r) {
- if(s) {
- var rs = Ext.decode(r.responseText);
- if(rs.data) {
- grid.productwh = rs.data;
- }
- }
- }
- });
- }
- },
- onQuery: function(){
- var grid = Ext.getCmp('grid');
- var me=this;
- this.setQty();
- if(!grid){
- grid = Ext.getCmp('batchDealGridPanel');
- }
- grid.multiselected = new Array();
- var form = Ext.getCmp('dealform');
- var cond = form.getCondition();
- if(Ext.isEmpty(cond)) {
- cond = '1=1';
- }
-
- if(Ext.getCmp('pr_whmanname') && Ext.getCmp('pr_whmanname').value !=null && Ext.getCmp('pr_whmanname').value !=''){
- var conds=cond.split("pr_whmanname");
- if(Ext.getCmp('ma_blank').checked==true){
- cond = conds[0]+'pr_whmanname is null or pr_whmanname'+conds[1];
- }
- }
- if(Ext.getCmp('pr_location') && Ext.getCmp('pr_location').value !=null && Ext.getCmp('pr_location').value !=''){
- var conds=cond.split("pr_location");
- if(Ext.getCmp('ifnulllocation').checked==true){
- cond = conds[0]+'pr_location is null or pr_location'+conds[1];
- }
- }
- cond+=" and nvl(mm_materialstatus,' ')=' '";
- var pushType=false; //判断是否考虑推式物料
- this.BaseUtil.getSetting(caller, 'pushSupplyType', function(v) {
- pushType=v;
- if (pushType!=true){
- cond+=" and pr_supplytype='PULL'";
- }
- form.beforeQuery(caller, cond);//执行查询前逻辑
- grid.getGridColumnsAndStore(grid, 'common/singleGridPanel.action',{caller: caller, condition: cond, start: 1, end: 1000}, "",true);
- var condition = "1=1";
- if(Ext.getCmp('ma_id').value != null&&Ext.getCmp('ma_id').value !=''){
- condition="( mp_maid="+Ext.getCmp('ma_id').value+")";
- }
- condition+=" and nvl(mm_materialstatus,' ')=' '";
- if (pushType!=true){
- condition+=" and pr_supplytype='PULL'";
- }
- me.showReplace(condition, grid);
- });
-
- },
- showReplace: function(condition, grid){
- Ext.Ajax.request({
- url : basePath + 'common/getFieldsDatas.action',
- params: {
- caller: 'MakeMaterialReplace left join MakeMaterial on mm_id=mp_mmid left join Product on mp_prodcode=pr_code' ,
- fields: 'mp_mmid,mp_detno,mp_thisqty,mp_canuseqty,mp_repqty,mp_prodcode,mp_whcode,pr_detail,pr_spec,'+
- 'pr_unit,mp_haverepqty,mp_thisplanqty,mp_wipuseqty,mp_canuseqty,mm_level,mm_oneuseqty,pr_wiponhand,pr_location',
- condition: condition + ' and (mp_thisqty > 0) order by mp_mmid,mp_detno'
- },
- async: false,
- method : 'post',
- callback : function(options,success,response){
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);return;
- }
- if(localJson.success){
- var data = Ext.decode(localJson.data);
- if(data && data.length > 0) {
- var idx=0, store = grid.store;
- grid.lockrender = true;
- Ext.each(data, function(d){
- Ext.Array.each(store.data.items,function(item,index){
- if(item.data.mm_id==d.MP_MMID){
- idx=index;
- return;
- }
- });
- record = store.getAt(idx);
- if(idx != null && idx >= 0) {
- store.insert(idx + 1, {
- mm_prodcode:d.MP_PRODCODE,
- mm_oneuseqty: d.MM_ONEUSEQTY,
- mm_qty: d.MP_CANUSEQTY,
- pr_detail: d.PR_DETAIL,
- pr_spec: d.PR_SPEC,
- pr_unit: d.PR_UNIT,
- mm_thisqty: d.MP_THISQTY,
- mm_totaluseqty: d.MP_REPQTY,
- mm_whcode: d.MP_WHCODE,
- mm_detno: d.MP_DETNO,
- mm_id: d.MP_MMID,
- havegetqty: d.MP_HAVEREPQTY,
- mm_level:d.MM_LEVEL,
- mm_thisplanqty:d.MP_THISPLANQTY,
- mm_wipuseqty:d.MP_WIPUSEQTY,
- pr_wiponhand:d.PR_WIPONHAND,
- isrep: true,
- pr_location:d.PR_LOCATION
- });
- }
- });
- grid.lockrender = false;
- }
- grid.store.fireEvent('load', grid.store);
- }
- }
- });
- },
- setQty: function(){
- var ma_id = Ext.getCmp('ma_id').value;
- var qty = Ext.getCmp('setqty').value;
- var wipwhcode = Ext.getCmp('ma_xbwhouse').value;
- if(qty==null || qty==''){
- qty = 0;
- }
- Ext.Ajax.request({
- url : basePath + 'pm/make/setLSThisQty.action',
- async: false,
- params: {
- caller:caller,
- ma_id:ma_id,
- qty:qty,
- wipwhcode:wipwhcode
- },
- callback: function(opt, s, r){
- var res = Ext.decode(r.responseText);
- if(res.exceptionInfo) {
- showError(res.exceptionInfo);
- }
- }
- });
- },
- create:function(grid){
- var me = this,
- material = this.getEffectData(grid.selModel.getSelection());
- var wipwhcode=Ext.getCmp('ma_xbwhouse').value;
- var pi_departmentcode="",pi_emcode="",pi_cgycode="";
- if (Ext.getCmp('ma_departmentcode')){
- pi_departmentcode=Ext.getCmp('ma_departmentcode').value;
- };
- if (Ext.getCmp('ms_recordorcode')){
- pi_emcode=Ext.getCmp('ms_recordorcode').value;
- };
- if (Ext.getCmp('pr_whmancode')){
- pi_cgycode=Ext.getCmp('pr_whmancode').value;
- };
- if(material.length > 0){
- grid.setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'pm/make/turnlssend.action',
- params: {
- data: Ext.encode(material),
- bywhcode: Ext.getCmp('bywhcode').checked,
- wipwhcode: wipwhcode,
- maid:Ext.getCmp('ma_id').value,
- caller:caller,
- departmentcode:pi_departmentcode,
- emcode:pi_emcode,
- cgycode:pi_cgycode
- },
- method : 'post',
- callback : function(options,success,response){
- grid.setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.log){
- showMessage('提示', localJson.log);
- }
- if(localJson.success){
- turnSuccess(function(){
-
- });
- }
- me.onQuery();
- }
- });
- }
-
- },
- getEffectData: function(items) {
- var d = new Array();
- var code = Ext.getCmp('ma_code').value;
- Ext.Array.each(items, function(item){
- if(item.get('mm_thisqty') > 0 || item.get('mm_thisplanqty') > 0) {
- d.push({
- mm_code: code,
- mm_id: item.get('isrep') == null ? item.get('mm_id') : -item.get('mm_id'),
- mm_detno: item.get('mm_detno'),
- mm_thisqty: item.get('mm_thisqty'),
- mm_thisplanqty: item.get('mm_thisplanqty'),
- mm_wipuseqty: item.get('mm_wipuseqty'),
- mm_whcode: item.get('mm_whcode'),
- mm_prodcode: item.get('mm_prodcode')
- });
- }
- });
- return d;
- },
- getId : function(code){
- var des = '';
- Ext.Ajax.request({
- url : basePath + 'pm/bom/getDescription.action',
- params: {
- tablename: "make",
- field: "ma_id",
- condition: "ma_code='"+code+"' and ma_statuscode='AUDITED'"
- },
- method : 'post',
- callback : function(options,success,response){
- var res = new Ext.decode(response.responseText);
- if(res.exceptionInfo){
- showError(res.exceptionInfo);return;
- }
- if(res.success && res.description != null){
- des = res.description;
- Ext.getCmp("ma_id").setValue(des);
- }else {
- showError("制造单编号非法或者未审核!");
- var store = Ext.getCmp("batchDealGridPanel").store;
- //清空所有
- store.removeAll();
- }
- }
- });
- return des;
- }
- });
|