| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- Ext.define('saas.view.purchase.purchaseIn.FormPanelController', {
- extend: 'saas.view.core.form.FormPanelController',
- alias: 'controller.purchase-purchasein-formpanel',
-
- init: function (form) {
- var me = this;
- this.control({
- /**放大镜新增demo*/
- "field[name=combo]":{
- beforerender:function(f){
- f.addHandler=me.addCombo;
- }
- },
- //放大镜赋值关系 以及 tpl模板
- 'dbfindtrigger[name=pi_vendname]':{
- beforerender:function(f){
- Ext.apply(f,{
- dbfinds:[{
- from:'id',to:'pi_vendid',ignore:true
- },{
- from:'ve_code',to:'pi_vendcode'
- },{
- from:'ve_name',to:'pi_vendname'
- }],
- }) ;
- }
- },
- //放大镜赋值关系 以及 tpl模板
- 'multidbfindtrigger[name=pd_prodcode]':{
- beforerender:function(f){
- Ext.apply(f,{
- dbfinds:[{
- from:'id',to:'pd_prodid',ignore:true
- },{
- from:'pr_code',to:'pd_prodcode'
- },{
- from:'pr_detail',to:'pr_detail'
- },{
- from:'pr_spec',to:'pr_spec'
- },{
- from: 'pr_brand', to: 'pr_brand'
- },{
- from: 'pr_orispeccode', to: 'pr_orispeccode'
- },{
- from: 'pr_unit', to: 'pr_unit'
- }, {
- from:'pr_whid',to:'pd_whid'
- },{
- from:'pr_whcode',to:'pd_whcode'
- },{
- from:'pr_whname',to:'pd_whname'
- },{
- from:'pr_purcprice',to:'pd_orderprice'
- }],
- });
- }
- },
- //放大镜赋值关系 以及 tpl模板
- 'dbfindtrigger[name=pd_whname]':{
- beforerender:function(f){
- Ext.apply(f,{
- dbfinds:[{
- from:'id',to:'pd_whid',ignore:true
- },{
- from:'wh_code',to:'pd_whcode'
- },{
- from:'wh_description',to:'pd_whname'
- }],
- }) ;
- }
- }
- });
- },
- addCombo:function(){
- var combo=this.ownerCmp;
- Ext.create('Ext.window.Window',{
- layout:'vbox',
- bodyPadding: 15,
- width:500,
- items:[{
- fieldLabel:'实际值',
- xtype:'textfield'
- },{
- fieldLabel:'显示值',
- xtype:'textfield'
- }],
- buttons:[{
- text:'确认',
- handler:function(b){
- combo.setValue('ok');
- b.up('window').close();
- }
- }],
- renderTo:this.ownerCmp.ownerCt.getEl()
- }).show();
- },
- initCopyData: function(formData) {
- var me = this;
- var form = this.getView();
- var detailCount = form.detailCount;
- var main = formData.main;
- var auditTexts = form.auditTexts;
- // 单号、id清空
- main[form._idField] = 0;
- main[form._codeField] = '';
- //采购单id,采购单号清空
- main['pi_puid'] = 0;
- main['pi_pucode'] = '';
- // 单据状态为录入状态(未审核)
- main[form._statusCodeField] = auditTexts.unAuditCode;
- main[form._statusField] = auditTexts.unAuditText;
- //重设录入人,录入日期,审核人,审核日期
- main['creatorId'] = saas.util.BaseUtil.getCurrentUser().id;
- main['creatorName'] = saas.util.BaseUtil.getCurrentUser().realname;
- main['createTime'] = Ext.Date.format(new Date(), 'Y-m-d H:i:s');
- main['updaterId'] = saas.util.BaseUtil.getCurrentUser().id;
- main['updaterName'] = saas.util.BaseUtil.getCurrentUser().realname;
- main['updateTime'] = Ext.Date.format(new Date(), 'Y-m-d H:i:s');
- main[form._auditmanField] = undefined;
- main[form._auditdateField] = undefined;
- for(var k in main) {
- // 主表日期改为当前日期
- if(saas.util.BaseUtil.isDateString(main[k])) {
- main[k] = Ext.Date.format(new Date, 'Y-m-d H:i:s');
- }
- }
- for(var j = 0; j < detailCount; j++) {
- var detail = formData['detail' + j];
- for(var x = 0; x < detail.length; x ++) {
- var d = detail[x];
- for(var k in d) {
- // 从表id清空
- delete d['id'];
- //采购单号清空
- delete d['pd_orderid'];
- delete d['pd_ordercode'];
- delete d['pd_orderdetno'];
- // 从表日期清空
- if(saas.util.BaseUtil.isDateString(d[k])) {
- d[k] = '';
- }
- }
- }
- }
- return me.myInitCopyData(formData);;
- },
- turnOut: function() {
- var me = this,
- form = me.getView(),
- id = form.getForm().findField(form._idField);
- form.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._turnOutUrl+'/'+id.value,
- method: 'POST',
- })
- .then(function(localJson) {
- form.setLoading(false);
- if(localJson.success){
- var intValue = localJson.data.id,
- codeValue= localJson.data.code,
- name = localJson.data.name;
- saas.util.BaseUtil.openTab('purchase-purchaseout-formpanel',name+"("+codeValue+")",codeValue+intValue, {
- initId: intValue
- });
- saas.util.BaseUtil.showSuccessToast('转单成功');
-
- }
- })
- .catch(function(res) {
- form.setLoading(false);
- console.error(res);
- saas.util.BaseUtil.showErrorToast('转单失败: ' + res.message);
- });
- }
- });
|