FormPanelController.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. Ext.define('saas.view.purchase.purchaseIn.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.purchase-purchasein-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. /**放大镜新增demo*/
  8. "field[name=combo]":{
  9. beforerender:function(f){
  10. f.addHandler=me.addCombo;
  11. }
  12. },
  13. //放大镜赋值关系 以及 tpl模板
  14. 'dbfindtrigger[name=pi_vendname]':{
  15. beforerender:function(f){
  16. Ext.apply(f,{
  17. dbfinds:[{
  18. from:'id',to:'pi_vendid',ignore:true
  19. },{
  20. from:'ve_code',to:'pi_vendcode'
  21. },{
  22. from:'ve_name',to:'pi_vendname'
  23. }],
  24. }) ;
  25. }
  26. },
  27. //放大镜赋值关系 以及 tpl模板
  28. 'multidbfindtrigger[name=pd_prodcode]':{
  29. beforerender:function(f){
  30. Ext.apply(f,{
  31. dbfinds:[{
  32. from:'id',to:'pd_prodid',ignore:true
  33. },{
  34. from:'pr_code',to:'pd_prodcode'
  35. },{
  36. from:'pr_detail',to:'pr_detail'
  37. },{
  38. from:'pr_spec',to:'pr_spec'
  39. },{
  40. from:'pr_whid',to:'pd_whid'
  41. },{
  42. from:'pr_whcode',to:'pd_whcode'
  43. },{
  44. from:'pr_whname',to:'pd_whname'
  45. },{
  46. from:'pr_purcprice',to:'pd_orderprice'
  47. }],
  48. });
  49. }
  50. },
  51. //放大镜赋值关系 以及 tpl模板
  52. 'dbfindtrigger[name=pd_whname]':{
  53. beforerender:function(f){
  54. Ext.apply(f,{
  55. dbfinds:[{
  56. from:'id',to:'pd_whid',ignore:true
  57. },{
  58. from:'wh_code',to:'pd_whcode'
  59. },{
  60. from:'wh_description',to:'pd_whname'
  61. }],
  62. }) ;
  63. }
  64. }
  65. });
  66. },
  67. addCombo:function(){
  68. var combo=this.ownerCmp;
  69. Ext.create('Ext.window.Window',{
  70. layout:'vbox',
  71. bodyPadding: 15,
  72. width:500,
  73. items:[{
  74. fieldLabel:'实际值',
  75. xtype:'textfield'
  76. },{
  77. fieldLabel:'显示值',
  78. xtype:'textfield'
  79. }],
  80. buttons:[{
  81. text:'确认',
  82. handler:function(b){
  83. combo.setValue('ok');
  84. b.up('window').close();
  85. }
  86. }],
  87. renderTo:this.ownerCmp.ownerCt.getEl()
  88. }).show();
  89. },
  90. initCopyData: function(formData) {
  91. var me = this;
  92. var form = this.getView();
  93. var detailCount = form.detailCount;
  94. var main = formData.main;
  95. var auditTexts = form.auditTexts;
  96. // 单号、id清空
  97. main[form._idField] = 0;
  98. main[form._codeField] = '';
  99. //采购单id,采购单号清空
  100. main['pi_puid'] = 0;
  101. main['pi_pucode'] = '';
  102. // 单据状态为录入状态(未审核)
  103. main[form._statusCodeField] = auditTexts.unAuditCode;
  104. main[form._statusField] = auditTexts.unAuditText;
  105. //录入人,录入日期,审核人,审核日期清空
  106. main['creatorId'] = null;
  107. main['creatorName'] = null;
  108. main['createTime'] = null;
  109. main['updaterId'] = null;
  110. main['updaterName'] = null;
  111. main['updateTime'] = null;
  112. main[form._auditmanField] = null;
  113. main[form._auditdateField] = null;
  114. for(var k in main) {
  115. // 主表日期改为当前日期
  116. if(saas.util.BaseUtil.isDateString(main[k])) {
  117. main[k] = Ext.Date.format(new Date, 'Y-m-d H:i:s');
  118. }
  119. }
  120. for(var j = 0; j < detailCount; j++) {
  121. var detail = formData['detail' + j];
  122. for(var x = 0; x < detail.length; x ++) {
  123. var d = detail[x];
  124. for(var k in d) {
  125. // 从表id清空
  126. delete d['id'];
  127. //采购单号清空
  128. delete d['pd_orderid'];
  129. delete d['pd_ordercode'];
  130. delete d['pd_orderdetno'];
  131. // 从表日期清空
  132. if(saas.util.BaseUtil.isDateString(d[k])) {
  133. d[k] = '';
  134. }
  135. }
  136. }
  137. }
  138. return me.myInitCopyData(formData);;
  139. },
  140. turnOut: function() {
  141. var me = this,
  142. form = me.getView(),
  143. id = form.getForm().findField(form._idField);
  144. saas.util.BaseUtil.request({
  145. url: form._turnOutUrl+'/'+id.value,
  146. method: 'POST',
  147. })
  148. .then(function(localJson) {
  149. if(localJson.success){
  150. var intValue = localJson.data.id,
  151. codeValue= localJson.data.code,
  152. name = localJson.data.name;
  153. saas.util.BaseUtil.openTab('purchase-purchaseout-formpanel',name+"("+codeValue+")",codeValue+intValue, {
  154. initId: intValue
  155. });
  156. saas.util.BaseUtil.showSuccessToast('转单成功');
  157. }
  158. })
  159. .catch(function(res) {
  160. console.error(res);
  161. saas.util.BaseUtil.showErrorToast('转单失败: ' + res.message);
  162. });
  163. }
  164. });