| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489 |
- Ext.QuickTips.init();
- Ext.define('erp.controller.scm.purchase.Inquiry', {
- extend: 'Ext.app.Controller',
- FormUtil: Ext.create('erp.util.FormUtil'),
- GridUtil: Ext.create('erp.util.GridUtil'),
- BaseUtil: Ext.create('erp.util.BaseUtil'),
- views:[
- 'core.form.Panel','scm.purchase.Inquiry','core.grid.Panel2','core.toolbar.Toolbar','core.form.FileField',
- 'core.button.Save','core.button.Update','core.button.Add','core.button.Submit','core.button.Print','core.button.Upload',
- 'core.button.Audit','core.button.Close','core.button.Delete','core.button.DeleteDetail','core.button.ResSubmit',
- 'core.button.ResAudit','core.button.HistoryQuotation','core.button.HistoryInPrice','core.button.UpdateMaxlimitInfo',
- 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField','core.button.TurnPurcPrice','core.button.AgreePrice','core.grid.YnColumn'
- ],
- init:function(){
- var me = this;
- me.alloweditor = true;
- this.control({
- 'erpGridPanel2': {
- afterrender: function(grid){
- var status = Ext.getCmp('in_statuscode');
- if(status && status.value != 'ENTERING' && status.value != 'COMMITED'){
- Ext.each(grid.columns, function(c){
- c.setEditor(null);
- });
- }
- },
- itemclick: this.onGridItemClick
- },
- 'erpSaveButton': {
- click: function(btn){
- var form = me.getForm(btn);
- if(Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == ''){
- me.BaseUtil.getRandomNumber();//自动添加编号
- }
- var bool = true;
- //供应商必填
- var grid = Ext.getCmp('grid'), start = Ext.getCmp('in_recorddate').value,
- end = Ext.getCmp('in_enddate').value;
- grid.getStore().each(function(item){
- if(item.dirty && item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ""){
- if(item.data['id_vendcode'] == null || item.data['id_vendcode'] == ''){
- bool = false;
- showError('明细表第' + item.data['id_detno'] + '行的供应商为空');return;
- }
- if(item.data['id_fromdate'] ==null){
- item.set('id_fromdate', start);
- }
- if(item.data['id_todate'] ==null){
- item.set('id_todate', end);
- }
- if(Ext.Date.format(item.data['id_fromdate'],'Y-m-d') > Ext.Date.format(item.data['id_todate'],'Y-m-d')){
- bool=false;
- showError('明细有效开始日期大于截止日期,不能保存!');return;
- }
- if(Ext.Date.format(item.data['id_fromdate'],'Y-m-d') < Ext.Date.format(new Date(),'Y-m-d')){
- bool=false;
- showError('明细有效开始日期小于当前日期,不能保存!');return;
- }
- }
- });
- if(bool){
- this.FormUtil.beforeSave(this);
- }
- }
- },
- 'erpUpdateButton': {
- click: function(btn){
- var bool = true;
- //供应商必填
- var grid = Ext.getCmp('grid'),
- fromDate = Ext.getCmp('in_recorddate').value,
- toDate = Ext.getCmp('in_enddate').value;
- grid.getStore().each(function(item){
- if(item.dirty && item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ""){
- if(item.data['id_vendcode'] == null || item.data['id_vendcode'] == ''){
- bool = false;
- showError('明细表第' + item.data['id_detno'] + '行的供应商为空');return;
- }
- if(item.data['id_fromdate'] ==null ){
- item.set('id_fromdate',fromDate);
- }
- if(item.data['id_todate'] ==null){
- item.set('id_todate',toDate);
- }
- if(Ext.Date.format(item.data['id_fromdate'],'Y-m-d') > Ext.Date.format(item.data['id_todate'],'Y-m-d')){
- bool = false;
- showError('明细有效开始日期大于截止日期,不能保存!');return;
- }
- console.log(Ext.Date.format(item.data['id_fromdate'],'Y-m-d'));
- if(Ext.Date.format(item.data['id_fromdate'],'Y-m-d') < Ext.Date.format(new Date(),'Y-m-d')){
- bool = false;
- showError('明细有效开始日期小于当前日期,不能保存!');return;
- }
- }
- });
- if(bool){
- this.FormUtil.onUpdate(this);
- }
- }
- },
- 'erpDeleteButton' : {
- click: function(btn){
- me.FormUtil.onDelete(Ext.getCmp('in_id').value);
- }
- },
- 'erpAddButton': {
- click: function(){
- me.FormUtil.onAdd('addInquiry', '新增询价单', 'jsps/scm/purchase/inquiry.jsp');
- }
- },
- 'erpUpdateMaxlimitInfoButton':{
- afterrender:function(btn){
- btn.setDisabled(true);
- },
- click: function(btn){
- var id=btn.ownerCt.ownerCt.ownerCt.items.items[1].selModel.selected.items[0].data["id_id"];
- var idstatus=btn.ownerCt.ownerCt.ownerCt.items.items[1].selModel.selected.items[0].data["id_status"];
- if(idstatus!='已报价'){
- showError("只能针对已报价的询价做限购");
- }else{
- var formCondition="id_id IS"+id;
- var linkCaller='InquiryMaxlimit';
- var win = new Ext.window.Window({
- id : 'win',
- height : '90%',
- width : '95%',
- maximizable : true,
- buttonAlign : 'center',
- layout : 'anchor',
- items : [ {
- tag : 'iframe',
- frame : true,
- anchor : '100% 100%',
- layout : 'fit',
- html : '<iframe id="iframe_'+linkCaller+'" src="'+basePath+'jsps/scm/purchase/inquiryMaxlimit.jsp?_noc=1&whoami='+linkCaller+'&formCondition='+formCondition+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>'
- } ],
- listeners:{
- 'beforeclose':function(view ,opt){
- //grid 刷新一次
- var grid=Ext.getCmp('grid');
- var gridParam = {caller: caller, condition: gridCondition};
- grid.GridUtil.getGridColumnsAndStore(grid, 'common/singleGridPanel.action', gridParam, "");
- Ext.getCmp('updateMaxlimitInfo').setDisabled(true);
- }
- }
- });
- win.show();
- }
- }
- },
- 'erpCloseButton': {
- click: function(btn){
- me.FormUtil.beforeClose(me);
- }
- },
- 'erpSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('in_statuscode');
- var checkstatus = Ext.getCmp('in_checkstatuscode').value;
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }else if(checkstatus&&checkstatus!=null&&checkstatus!='ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- /*Ext.getCmp('in_kind').setValue = 'ss';
- Ext.getCmp('in_enddate').setValue= 'ss';
- console.log('ce');
- me.FormUtil.onSubmit(Ext.getCmp('in_id').value);*/
- var inclass = Ext.getCmp('in_class');
- if(inclass&&inclass.value=='主动报价'){
- me.FormUtil.getActiveTab().setLoading(true);
- Ext.Ajax.request({
- url : basePath + 'scm/purchase/submitInquiry.action',
- params: {
- id: Ext.getCmp('in_id').value
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- window.location.reload();
- }
- }
- });
- }else{
- me.FormUtil.onSubmit(Ext.getCmp('in_id').value);
- }
-
- }
- },
- 'erpResSubmitButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('in_checkstatuscode');
- if(status && status.value != 'COMMITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResSubmit(Ext.getCmp('in_id').value);
- }
- },
- 'erpAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('in_statuscode');
- if(status && status.value != 'ENTERING'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onAudit(Ext.getCmp('in_id').value);
- }
- },
- 'erpResAuditButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('in_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- me.FormUtil.onResAudit(Ext.getCmp('in_id').value);
- }
- },
- 'erpPrintButton': {
- click: function(btn){
- me.FormUtil.onPrint(Ext.getCmp('in_id').value);
- }
- },
- 'erpAgreePriceButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('in_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- var appstatus = Ext.getCmp('in_checkstatuscode');
- if(appstatus && appstatus.value == 'APPROVED'){
- showError('审批完成的询价单不能进行最终判定!');return;
- }else{
- inid=Ext.getCmp('in_id').value;
- var url = basePath+'jsps/common/vastDatalist.jsp?_noc=1&whoami=ToPrice&urlcondition=id_inid='+inid+' and nvl(id_price,0)>0';
- var main = parent.parent.Ext.getCmp("content-panel");
- var panelId='Inquiry' + id;
- var title='采购询价转核价' + id;
- if(main){
- panelId = panelId == main.getActiveTab().id ? Math.random() : panelId;
- var panel = Ext.getCmp(panelId);
- if(!panel){
- var value = "";
- if (title.toString().length>5) {
- value = title.toString().substring(0,5);
- } else {
- value = title;
- }
- if(!contains(url, 'http://', true) && !contains(url, basePath, true)){
- url = basePath + url;
- }
- panel = {
- title : value,
- tag : 'iframe',
- tabConfig:{tooltip:title},
- frame : true,
- border : false,
- layout : 'fit',
- iconCls : 'x-tree-icon-tab-tab',
- html : '<iframe id="iframe_add_'+panelId+'" src="' + url+'" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
- closable : true
- };
- me.FormUtil.openTab(panel, panelId);
- } else {
- main.setActiveTab(panel);
- }
- } else {
- if(!contains(url, basePath, true)){
- url = basePath + url;
- }
- window.open(url);
- }
- }
-
- //me.FormUtil.onPrint(Ext.getCmp('in_id').value);
- }
- },
- 'erpTurnPurcPriceButton': {
- afterrender: function(btn){
- var status = Ext.getCmp('in_statuscode');
- if(status && status.value != 'AUDITED'){
- btn.hide();
- }
- },
- click: function(btn){
- warnMsg("确定要转入物料核价单吗?", function(btn){
- if(btn == 'yes'){
- me.FormUtil.getActiveTab().setLoading(true);//loading...
- Ext.Ajax.request({
- url : basePath + 'scm/purchase/turnPurcPrice.action',
- params: {
- id: Ext.getCmp('in_id').value
- },
- method : 'post',
- callback : function(options,success,response){
- me.FormUtil.getActiveTab().setLoading(false);
- var localJson = new Ext.decode(response.responseText);
- if(localJson.exceptionInfo){
- showError(localJson.exceptionInfo);
- }
- if(localJson.success){
- turnSuccess(function(){
- var id = localJson.id;
- var url = "jsps/scm/purchase/purchasePrice.jsp?formCondition=pp_id=" + id +
- "&gridCondition=ppd_ppid=" + id;
- me.FormUtil.onAdd('PurchasePrice' + id, '物料核价单' + id, url);
- });
- }
- }
- });
- }
- });
- }
- },
- /**
- * 查看历史入库价
- */
- 'button[id=historyin]': {
- click: function(){
- var record = Ext.getCmp('grid').selModel.lastSelected;
- if(record){
- var prod = record.data['id_prodcode'];
- var win = Ext.getCmp('in-win');
- if(win == null){
- win = Ext.create('Ext.window.Window', {
- id: 'in-win',
- width: '80%',
- height: '100%',
- maximizable : true,
- layout: 'anchor',
- closeAction: 'hide',
- items: [Ext.create('erp.view.core.grid.Panel2', {
- id: 'inhistory',
- anchor: '100% 100%',
- caller: 'ProdInOut!In!History',
- condition: "pd_prodcode='" + prod + "' order by pd_prodmadedate desc",
- bbar: null
- })],
- setMyTitle: function(code){//@param code 料号
- this.setTitle('编号:<font color=blue>' + code + '</font> 的历史入库价 ' +
- '<input type="button" value="上一条" onClick="javascript:Ext.getCmp(\'in-win\').prev();" style="cursor: pointer;color:gray;font-size:13px;"/>' +
- '<input type="button" value="下一条" onClick="javascript:Ext.getCmp(\'in-win\').next();" style="cursor: pointer;color:gray;font-size:13px;"/>');
- },
- reload: function(code){//@param code 料号
- var g = this.down('grid[id=inhistory]');
- g.GridUtil.loadNewStore(g, {
- caller: g.caller,
- condition: "pd_prodcode='" + code + "' order by pd_prodmadedate desc"
- });
- this.setMyTitle(code);
- },
- prev: function(){//查看上一条
- var item = Ext.getCmp('grid').prev();
- if(item != null){
- this.reload(item.data['id_prodcode']);
- }
- },
- next: function(){//查看下一条
- var item = Ext.getCmp('grid').next();
- if(item != null){
- this.reload(item.data['id_prodcode']);
- }
- }
- });
- win.setMyTitle(prod);
- win.show();
- } else {
- win.reload(prod);
- win.show();
- }
- } else {
- alert("请先选择明细!");
- }
- }
- },
- /**
- * 查看历史报价
- */
- 'button[id=historyquo]': {
- click: function(){
- var record = Ext.getCmp('grid').selModel.lastSelected;
- if(record){
- var prod = record.data['id_prodcode'];
- var win = Ext.getCmp('history-win');
- if(win == null){
- win = Ext.create('Ext.window.Window', {
- id: 'history-win',
- width: '80%',
- height: '100%',
- maximizable : true,
- layout: 'anchor',
- closeAction: 'hide',
- setMyTitle: function(code){//@param code 料号
- this.setTitle('编号:<font color=blue>' + code + '</font> 的报价历史 ' +
- '<input type="button" value="上一条" onClick="javascript:Ext.getCmp(\'history-win\').prev();" style="cursor: pointer;color:gray;font-size:13px;"/>' +
- '<input type="button" value="下一条" onClick="javascript:Ext.getCmp(\'history-win\').next();" style="cursor: pointer;color:gray;font-size:13px;"/>');
- },
- reload: function(code){//@param code 料号
- var g = this.down('grid[id=history]');
- g.GridUtil.loadNewStore(g, {
- caller: g.caller,
- condition: "id_prodcode='" + code + "'"
- });
- g = this.down('grid[id=invid]');
- g.GridUtil.loadNewStore(g, {
- caller: g.caller,
- condition: "ppd_prodcode='" + code + "' AND ppd_statuscode='VALID'"
- });
- this.setMyTitle(code);
- },
- prev: function(){//查看上一条
- var item = Ext.getCmp('grid').prev();
- if(item != null){
- this.reload(item.data['id_prodcode']);
- }
- },
- next: function(){//查看下一条
- var item = Ext.getCmp('grid').next();
- if(item != null){
- this.reload(item.data['id_prodcode']);
- }
- }
- });
- win.setMyTitle(prod);
- win.show();
- win.add(Ext.create('erp.view.core.grid.Panel2', {
- id: 'history',
- anchor: '100% 60%',
- caller: 'Inquiry!History',
- condition: "id_prodcode='" + prod + "'",
- bbar: null,
- listeners: {
- reconfigure: function(){
- win.add(Ext.create('erp.view.core.grid.Panel2', {
- id: 'invid',
- title: '现有效价格',
- anchor: '100% 40%',
- caller: 'PurchasePrice!Invid',
- condition: "ppd_prodcode='" + prod + "' AND ppd_statuscode='VALID'",
- bbar: null
- }));
- }
- }
- }));
- } else {
- win.reload(prod);
- win.show();
- }
- } else {
- alert("请先选择明细!");
- }
- }
- }
- });
- },
- onGridItemClick: function(selModel, record){//grid行选择
- this.GridUtil.onGridItemClick(selModel, record);
- var grid=selModel.ownerCt;
- var show=0;
- Ext.Array.each(grid.necessaryFields, function(field) {
- var fieldValue=record.data[field];
- if(fieldValue==undefined||fieldValue==""||fieldValue==null){
- show=1;
- return;
- }
- });
- if(show==1){
- Ext.getCmp('updateMaxlimitInfo').setDisabled(true);
- }else {
- Ext.getCmp('updateMaxlimitInfo').setDisabled(false);
- }
- },
- getForm: function(btn){
- return btn.ownerCt.ownerCt;
- }
- });
|