FormPanelController.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. Ext.define('saas.view.money.verification.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.money-verification-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. // 客户
  8. 'dbfindtrigger[name=vc_custname]':{
  9. beforerender:function(f){
  10. Ext.apply(f,{
  11. //赋值
  12. dbfinds:[{
  13. from: 'id', to: 'vc_custid',ignore:true
  14. }, {
  15. from:'cu_code', to:'vc_custcode'
  16. },{
  17. from:'cu_name', to:'vc_custname'
  18. }],
  19. }) ;
  20. }
  21. },
  22. // 转出客户
  23. 'dbfindtrigger[name=vc_outcustname]':{
  24. beforerender:function(f){
  25. Ext.apply(f,{
  26. //赋值
  27. dbfinds:[{
  28. from: 'id', to: 'vc_outcustid',ignore:true
  29. }, {
  30. from:'cu_code', to:'vc_outcustcode'
  31. },{
  32. from:'cu_name', to:'vc_outcustname'
  33. }],
  34. }) ;
  35. }
  36. },
  37. // 转入客户
  38. 'dbfindtrigger[name=vc_turncustname]':{
  39. beforerender:function(f){
  40. Ext.apply(f,{
  41. //赋值
  42. dbfinds:[{
  43. from: 'id', to: 'vc_turncustid',ignore:true
  44. }, {
  45. from:'cu_code', to:'vc_turncustcode'
  46. },{
  47. from:'cu_name', to:'vc_turncustname'
  48. }],
  49. }) ;
  50. }
  51. },
  52. // 供应商
  53. 'dbfindtrigger[name=vc_vendname]':{
  54. beforerender: function (f) {
  55. Ext.apply(f, {
  56. dbfinds: [{
  57. from: 'id',
  58. to: 'vc_vendid',
  59. ignore: true
  60. }, {
  61. from: 've_code',
  62. to: 'vc_vendcode'
  63. }, {
  64. from: 've_name',
  65. to: 'vc_vendname'
  66. }],
  67. });
  68. }
  69. },
  70. // 转出供应商
  71. 'dbfindtrigger[name=vc_outvendname]':{
  72. beforerender: function (f) {
  73. Ext.apply(f, {
  74. dbfinds: [{
  75. from: 'id',
  76. to: 'vc_outvendid',
  77. ignore: true
  78. }, {
  79. from: 've_code',
  80. to: 'vc_outvendcode'
  81. }, {
  82. from: 've_name',
  83. to: 'vc_outvendname'
  84. }],
  85. });
  86. }
  87. },
  88. // 转入供应商
  89. 'dbfindtrigger[name=vc_turnvendname]':{
  90. beforerender: function (f) {
  91. Ext.apply(f, {
  92. dbfinds: [{
  93. from: 'id',
  94. to: 'vc_turncustid',
  95. ignore: true
  96. }, {
  97. from: 've_code',
  98. to: 'vc_turnvendcode'
  99. }, {
  100. from: 've_name',
  101. to: 'vc_turnvendname'
  102. }],
  103. });
  104. }
  105. },
  106. // 来源单号1
  107. 'oriOrderMutiDbfindTrigger[name=vd_slcode]': {
  108. beforerender: function (f) {
  109. Ext.apply(f, {
  110. dbfinds: [{
  111. from: 'id',
  112. to: 'vd_slid',ignore:true
  113. }, {
  114. from: 'sl_code',
  115. to: 'vd_slcode'
  116. },{
  117. from: 'sl_orderamount',
  118. to: 'vd_amount'
  119. },{
  120. from: 'sl_yamount',
  121. to: 'sl_yamount'
  122. },{
  123. from:'sl_date',
  124. to:'vd_sldate'
  125. },{
  126. from:'sl_kind',
  127. to:'vd_slkind'
  128. },{
  129. from: 'sl_namount',
  130. to: 'vd_nowbalance'
  131. }],
  132. });
  133. },
  134. beforequery: function(f) {
  135. var defaultCondition = this.getDefaultCondition(0);
  136. if(!defaultCondition) {
  137. return false;
  138. }
  139. Ext.apply(f, {
  140. defaultCondition: defaultCondition
  141. });
  142. },
  143. beforetriggerclick: function(f) {
  144. var defaultCondition = this.getDefaultCondition(0);
  145. if(!defaultCondition) {
  146. return false;
  147. }
  148. Ext.apply(f, {
  149. defaultCondition: defaultCondition
  150. });
  151. }
  152. },
  153. // 来源单号2
  154. 'oriOrderMutiDbfindTrigger[name=vcd_slcode]': {
  155. beforerender: function (f) {
  156. Ext.apply(f, {
  157. dbfinds: [{
  158. from: 'id',
  159. to: 'vcd_slid',ignore:true
  160. }, {
  161. from: 'sl_code',
  162. to: 'vcd_slcode'
  163. },{
  164. from: 'sl_orderamount',
  165. to: 'vcd_amount'
  166. },{
  167. from: 'sl_yamount',
  168. to: 'sl_yamount'
  169. },,{
  170. from: 'sl_namount',
  171. to: 'sl_namount'
  172. },{
  173. from:'sl_date',
  174. to:'vcd_sldate'
  175. },{
  176. from:'sl_kind',
  177. to:'vcd_slkind'
  178. },{
  179. from: 'sl_namount',
  180. to: 'vcd_nowbalance'
  181. }],
  182. });
  183. },
  184. beforequery: function(f) {
  185. var defaultCondition = this.getDefaultCondition(1);
  186. if(!defaultCondition) {
  187. return false;
  188. }
  189. Ext.apply(f, {
  190. defaultCondition: defaultCondition
  191. });
  192. },
  193. beforetriggerclick: function(f) {
  194. var defaultCondition = this.getDefaultCondition(1);
  195. if(!defaultCondition) {
  196. return false;
  197. }
  198. Ext.apply(f, {
  199. defaultCondition: defaultCondition
  200. });
  201. }
  202. },
  203. });
  204. },
  205. getDefaultCondition: function(idx) {
  206. var me = this,
  207. form = me.getView(),
  208. formItems = form.formItems,
  209. viewModel = me.getViewModel(),
  210. acitveType = form.acitveType,
  211. etc = form.etc,
  212. defaultConditions = etc.defaultConditions,
  213. defaultConditionMode = defaultConditions[acitveType][idx];
  214. var reg = /(.*){(.*)}(.*)/g;
  215. var fieldName = defaultConditionMode.match(/(.*){(.*)}(.*)/)[2];
  216. var fieldLabel = Ext.Array.findBy(formItems, function(f) {
  217. return f.name == fieldName;
  218. }).fieldLabel;
  219. var fieldValue = viewModel.get(fieldName);
  220. if(!fieldValue) {
  221. saas.util.BaseUtil.showErrorToast('请先录入主表字段【' + '<span style="color: red;">' + fieldLabel + '</span>】');
  222. return null;
  223. }
  224. var defaultCondition = defaultConditionMode.replace(reg, '$1' + fieldValue + '$3');
  225. return defaultCondition;
  226. },
  227. /**
  228. * 清空所有从表数据
  229. */
  230. clearDetails: function() {
  231. var me = this;
  232. me.clearDetail0();
  233. me.clearDetail1();
  234. },
  235. /**
  236. * 清空第一个从表数据
  237. */
  238. clearDetail0: function(f, n, o) {
  239. var me = this,
  240. form = me.getView(),
  241. grid = form.query('detailGridField')[0];
  242. me.clearDetail(grid);
  243. },
  244. /**
  245. * 清空第二个从表数据
  246. */
  247. clearDetail1: function() {
  248. var me = this,
  249. form = me.getView(),
  250. grid = form.query('detailGridField')[1];
  251. me.clearDetail(grid);
  252. },
  253. /**
  254. * 清空一个从表数据
  255. */
  256. clearDetail: function(grid) {
  257. var datas = [],
  258. emptyRows = grid.emptyRows,
  259. detnoColumn = grid.detnoColumn,
  260. detno = 0,
  261. store = grid.getStore();
  262. Ext.Array.each(new Array(emptyRows), function() {
  263. detno += 1;
  264. var data = {};
  265. data[detnoColumn] = detno;
  266. datas.push(data);
  267. })
  268. store.removeAll();
  269. store.add(datas);
  270. },
  271. });