FormPanelController.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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: 'vd_slid',ignore:true
  160. }, {
  161. from: 'sl_code',
  162. to: 'vd_slcode'
  163. },{
  164. from: 'sl_orderamount',
  165. to: 'vd_amount'
  166. },{
  167. from: 'sl_yamount',
  168. to: 'sl_yamount'
  169. },{
  170. from:'sl_date',
  171. to:'vd_sldate'
  172. },{
  173. from:'sl_kind',
  174. to:'vd_slkind'
  175. },{
  176. from: 'sl_namount',
  177. to: 'vd_nowbalance'
  178. }],
  179. });
  180. },
  181. beforequery: function(f) {
  182. var defaultCondition = this.getDefaultCondition(1);
  183. if(!defaultCondition) {
  184. return false;
  185. }
  186. Ext.apply(f, {
  187. defaultCondition: defaultCondition
  188. });
  189. },
  190. beforetriggerclick: function(f) {
  191. var defaultCondition = this.getDefaultCondition(1);
  192. if(!defaultCondition) {
  193. return false;
  194. }
  195. Ext.apply(f, {
  196. defaultCondition: defaultCondition
  197. });
  198. }
  199. },
  200. });
  201. },
  202. getDefaultCondition: function(idx) {
  203. var me = this,
  204. form = me.getView(),
  205. formItems = form.formItems,
  206. viewModel = me.getViewModel(),
  207. acitveType = form.acitveType,
  208. etc = form.etc,
  209. defaultConditions = etc.defaultConditions,
  210. defaultConditionMode = defaultConditions[acitveType][idx];
  211. var reg = /(.*){(.*)}(.*)/g;
  212. var fieldName = defaultConditionMode.match(/(.*){(.*)}(.*)/)[2];
  213. var fieldLabel = Ext.Array.findBy(formItems, function(f) {
  214. return f.name == fieldName;
  215. }).fieldLabel;
  216. var fieldValue = viewModel.get(fieldName);
  217. if(!fieldValue) {
  218. saas.util.BaseUtil.showErrorToast('请先录入主表字段【' + '<span style="color: red;">' + fieldLabel + '</span>】');
  219. return null;
  220. }
  221. var defaultCondition = defaultConditionMode.replace(reg, '$1' + fieldValue + '$3');
  222. return defaultCondition;
  223. },
  224. /**
  225. * 清空所有从表数据
  226. */
  227. clearDetails: function() {
  228. var me = this;
  229. me.clearDetail0();
  230. me.clearDetail1();
  231. },
  232. /**
  233. * 清空第一个从表数据
  234. */
  235. clearDetail0: function(f, n, o) {
  236. var me = this,
  237. form = me.getView(),
  238. grid = form.query('detailGridField')[0];
  239. me.clearDetail(grid);
  240. },
  241. /**
  242. * 清空第二个从表数据
  243. */
  244. clearDetail1: function() {
  245. var me = this,
  246. form = me.getView(),
  247. grid = form.query('detailGridField')[1];
  248. me.clearDetail(grid);
  249. },
  250. /**
  251. * 清空一个从表数据
  252. */
  253. clearDetail: function(grid) {
  254. var datas = [],
  255. emptyRows = grid.emptyRows,
  256. detnoColumn = grid.detnoColumn,
  257. detno = 0,
  258. store = grid.getStore();
  259. Ext.Array.each(new Array(emptyRows), function() {
  260. detno += 1;
  261. var data = {};
  262. data[detnoColumn] = detno;
  263. datas.push(data);
  264. })
  265. store.removeAll();
  266. store.add(datas);
  267. },
  268. });