FormPanelController.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. Ext.define('saas.view.money.recBalance.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.money-recbalance-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. 'dbfindtrigger[name=rb_custname]':{
  8. beforerender:function(f){
  9. Ext.apply(f,{
  10. //数据接口
  11. dataUrl: '/api/document/customer/list',
  12. addXtype: 'document-customer-formpanel',
  13. addTitle: '客户资料',
  14. //赋值
  15. dbfinds:[{
  16. from: 'id', to: 'rb_custid'
  17. }, {
  18. from:'cu_code', to:'rb_custcode'
  19. },{
  20. from:'cu_name', to:'rb_custname'
  21. },{
  22. from:'cu_leftamount', to:'cu_leftamount'
  23. }],
  24. //联想设置
  25. dbtpls:[{
  26. field:'cu_code',width:100
  27. },{
  28. field:'cu_name',width:100
  29. },{
  30. field:'cu_leftamount',width:100
  31. }],
  32. defaultCondition: 'cu_statuscode="OPEN"',
  33. dbSearchFields:[{
  34. emptyText:'输入客户编号或名称',
  35. xtype : "textfield",
  36. name : "search",
  37. getCondition: function(v) {
  38. return "(upper(cu_code) like '%"+v.toUpperCase()+"%' or upper(cu_name) like '%"+v.toUpperCase()+"%')";
  39. },
  40. allowBlank : true,
  41. columnWidth : 0.25
  42. }],
  43. //放大镜窗口列表
  44. dbColumns:[{
  45. "text": "客户ID",
  46. "hidden": true,
  47. "dataIndex": "id",
  48. },{
  49. "text": "客户编号",
  50. "dataIndex": "cu_code",
  51. "width": 200,
  52. }, {
  53. "text": "客户名称",
  54. "dataIndex": "cu_name",
  55. "width": 200
  56. },{
  57. "text": "客户类型",
  58. "dataIndex": "cu_name",
  59. "width": 100
  60. },{
  61. "text": "业务员",
  62. "dataIndex": "cu_sellername",
  63. "width": 100
  64. },{
  65. "text": "应收款余额",
  66. "dataIndex": "cu_leftamount",
  67. "width": 100,
  68. xtype: 'numbercolumn',
  69. align:'end'
  70. },{
  71. "text": "税率",
  72. "dataIndex": "cu_taxrate",
  73. "width": 100,
  74. xtype: 'numbercolumn',
  75. align:'end'
  76. },{
  77. "text": "承付天数",
  78. "dataIndex": "cu_promisedays",
  79. "width": 100,
  80. xtype: 'numbercolumn',
  81. align:'end'
  82. },{
  83. "text": "额度",
  84. "dataIndex": "cu_credit",
  85. "width": 100,
  86. xtype: 'numbercolumn',
  87. align:'end'
  88. }]
  89. }) ;
  90. }
  91. },
  92. 'multidbfindtrigger[name=rbd_slcode]': {
  93. beforerender: function (f) {
  94. Ext.apply(f, {
  95. dataUrl: '/api/money/subledger/list',
  96. addTitle: '源单资料',
  97. dbfinds: [{
  98. from: 'id',
  99. to: 'rbd_slid'
  100. }, {
  101. from: 'sl_code',
  102. to: 'rbd_slcode'
  103. },{
  104. from: 'sl_orderamount',
  105. to: 'rbd_amount'
  106. },{
  107. from: 'sl_yamount',
  108. to: 'sl_yamount'
  109. },{
  110. from: 'sl_namount',
  111. to: 'sl_namount'
  112. },{
  113. from:'sl_date',
  114. to:'rbd_sldate'
  115. },{
  116. from:'sl_kind',
  117. to:'rbd_slkind'
  118. },{
  119. from: 'sl_namount',
  120. to: 'rbd_nowbalance'
  121. }],
  122. dbtpls: [{
  123. field: 'sl_code',
  124. width: 100
  125. }],
  126. defaultCondition: "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0",
  127. dbSearchFields:[{
  128. emptyText:'输入源单编号',
  129. xtype : "textfield",
  130. name : "search",
  131. getCondition: function(v) {
  132. return "(upper(sl_code) like '%"+v.toUpperCase()+"%')";
  133. },
  134. allowBlank : true,
  135. columnWidth : 0.25
  136. }],
  137. dbColumns:[{
  138. "text": "源单id",
  139. "hidden": true,
  140. "dataIndex": "id",
  141. "width": 100,
  142. "xtype": "numbercolumn"
  143. },{
  144. "text": "源单编号",
  145. "flex": 1,
  146. "dataIndex": "sl_code",
  147. "width": 100
  148. }, {
  149. "text": "源单类型",
  150. "flex": 1,
  151. "dataIndex": "sl_kind",
  152. "width": 100
  153. },{
  154. "text": "单据金额",
  155. "flex": 1,
  156. "dataIndex": "sl_orderamount",
  157. "width": 100,
  158. xtype: 'numbercolumn',
  159. align:'end'
  160. }, {
  161. "text": "已核销金额",
  162. "flex": 0,
  163. "dataIndex": "sl_yamount",
  164. "width": 200,
  165. "items": null,
  166. xtype: 'numbercolumn',
  167. align:'end'
  168. }, {
  169. "text": "未核销金额",
  170. "flex": 1,
  171. "dataIndex": "sl_namount",
  172. "width": 100,
  173. xtype: 'numbercolumn',
  174. align:'end'
  175. },{
  176. "text": "单据日期",
  177. "flex": 1,
  178. "dataIndex": "sl_date",
  179. "width": 120,
  180. xtype: 'datecolumn',
  181. align:'end'
  182. }]
  183. });
  184. }
  185. },
  186. 'dbfindtrigger[name=rd_bankname]':{
  187. beforerender: function (f) {
  188. Ext.apply(f, {
  189. dataUrl: '/api/document/bankinformation/list',
  190. // addXtype: 'document-banksubledger-formpanel',
  191. addTitle: '账户资料',
  192. dbfinds: [{
  193. from: 'id',
  194. to: 'rd_bankid'
  195. }, {
  196. from: 'bk_bankcode',
  197. to: 'rd_bankcode'
  198. },{
  199. from: 'bk_bankname',
  200. to: 'rd_bankname'
  201. }],
  202. dbtpls: [{
  203. field: 'bk_bankcode',
  204. width: 100
  205. }, {
  206. field: 'bk_bankname',
  207. width: 100
  208. }],
  209. defaultCondition: "1=1",
  210. dbSearchFields:[{
  211. emptyText:'输入账户名称或者编号',
  212. xtype : "textfield",
  213. name : "search",
  214. getCondition: function(v) {
  215. return "(upper(bk_bankcode) like '%"+v.toUpperCase()+"%' or upper(bk_bankname) like '%"+v.toUpperCase()+"%')";
  216. },
  217. allowBlank : true,
  218. columnWidth : 0.25
  219. }],
  220. dbColumns:[{
  221. "text": "账户id",
  222. "hidden": true,
  223. "dataIndex": "id",
  224. "width": 0,
  225. "xtype": "numbercolumn"
  226. },{
  227. "text": "账户编号",
  228. "flex": 1,
  229. "dataIndex": "bk_bankcode",
  230. "width": 100
  231. }, {
  232. "text": "账户名称",
  233. "flex": 1,
  234. "dataIndex": "bk_bankname",
  235. "width": 100
  236. }]
  237. });
  238. }
  239. }
  240. });
  241. },
  242. addCombo:function(){
  243. var combo=this.ownerCmp;
  244. Ext.create('Ext.window.Window',{
  245. layout:'vbox',
  246. bodyPadding: 15,
  247. width:500,
  248. items:[{
  249. fieldLabel:'实际值',
  250. xtype:'textfield'
  251. },{
  252. fieldLabel:'显示值',
  253. xtype:'textfield'
  254. }],
  255. buttons:[{
  256. text:'确认',
  257. handler:function(b){
  258. combo.setValue('ok');
  259. b.up('window').close();
  260. }
  261. }],
  262. renderTo:this.ownerCmp.ownerCt.getEl()
  263. }).show();
  264. },
  265. turnIn: function() {
  266. var me = this,
  267. form = me.getView(),
  268. id = form.getForm().findField(form._idField);
  269. form.BaseUtil.request({
  270. url: form._turnInUrl+id.value,
  271. method: 'GET',
  272. })
  273. .then(function(localJson) {
  274. if(localJson.success){
  275. showToast('转单成功');
  276. }
  277. })
  278. .catch(function(res) {
  279. console.error(res);
  280. showToast('转单失败: ' + res.message);
  281. });
  282. },
  283. onSave: function() {
  284. var me = this,
  285. form = me.getView(),
  286. viewModel = me.getViewModel(),
  287. store1 = viewModel.get('detail0').detailStore,
  288. store2 = viewModel.get('detail1').detailStore;
  289. var valid = form.isValid();
  290. if(!valid) {
  291. showToast(form.invalidText);
  292. return false;
  293. }
  294. var sum_rd_amount = store1.sum('rd_amount'); // 付款金额合计
  295. var rb_discounts = viewModel.get('rb_discounts'); // 折扣金额
  296. var sum_rbd_nowbalance = store2.sum('rbd_nowbalance'); // 本次核销金额合计
  297. var flag = sum_rd_amount + rb_discounts - sum_rbd_nowbalance;
  298. viewModel.set("rb_preamount",flag);
  299. if(flag != 0) {
  300. var t = flag > 0 ? '大' : '小';
  301. showConfirm('提示', '收款金额' + t + '于本次折扣后核销金额,是否仍要保存?')
  302. .then(function(y) {
  303. if(y == 'yes') {
  304. me.save();
  305. }
  306. });
  307. }else {
  308. me.save();
  309. }
  310. },
  311. custnamechange:function(dbfindtrigger){
  312. var me = this,
  313. viewModel = me.getViewModel();
  314. var c = viewModel.get('rb_custname_change');
  315. if(c!=null&&c!=''){
  316. c = ' and sl_custid='+c;
  317. }else{
  318. c ='';
  319. }
  320. dbfindtrigger.defaultCondition = "sl_custid<>0 and sl_kind in ('期初余额','出货单','销售退货单') and sl_namount<>0" + c;
  321. }
  322. });