FormPanelController.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. Ext.define('make.view.osmake.osMakePick.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.osmake-osmakepick-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. //放大镜赋值关系 以及 tpl模板
  8. 'dbfindtrigger[name=pi_vendname]':{
  9. beforerender:function(f){
  10. Ext.apply(f,{
  11. dbfinds:[{
  12. from:'id',to:'pi_vendid',ignore:true
  13. },{
  14. from:'ve_code',to:'pi_vendcode'
  15. },{
  16. from:'ve_name',to:'pi_vendname'
  17. },{
  18. from:'ve_buyerid',to:'pi_buyerid'
  19. },{
  20. from:'ve_buyercode',to:'pi_buyercode'
  21. },{
  22. from:'ve_buyername',to:'pi_buyername'
  23. },{
  24. from:'ve_currency',to:'pi_currency'
  25. },{
  26. from:'cr_rate',to:'pi_rate'
  27. },{
  28. from:'vc_name',to:'pi_contact'
  29. },{
  30. from:'vc_tel',to:'pi_tel'
  31. },{
  32. from:'ve_paymentsid',to:'pi_paymentsid'
  33. },{
  34. from:'ve_paymentscode',to:'pi_paymentscode'
  35. },{
  36. from:'ve_payments',to:'pi_payments'
  37. },{
  38. from:'ve_taxrate',to:'pi_taxrate'
  39. }],
  40. }) ;
  41. }
  42. },
  43. //从表多选放大镜赋值关系 以及 tpl模板
  44. 'multidbfindtrigger[name=pd_prodcode]':{
  45. beforerender:function(f){
  46. Ext.apply(f,{
  47. //放大镜赋值设置
  48. dbfinds:[{
  49. from:'id',to:'pd_prodid',ignore:true
  50. },{
  51. from:'pr_code',to:'pd_prodcode'
  52. },{
  53. from:'pr_detail',to:'pr_detail'
  54. },{
  55. from:'pr_spec',to:'pr_spec'
  56. },{
  57. from: 'pr_brand', to: 'pr_brand'
  58. },{
  59. from: 'pr_orispeccode', to: 'pr_orispeccode'
  60. },{
  61. from: 'pr_unit', to: 'pr_unit'
  62. }, {
  63. from:'pr_purcprice',to:'pd_lastprice'
  64. },{
  65. from:'pr_zxbzs',to:'pr_zxbzs'
  66. }],
  67. });
  68. }
  69. },
  70. 'multidbfindtrigger[name=pr_detail]': {
  71. beforerender: function (f) {
  72. Ext.apply(f, {
  73. dbfinds:[{
  74. from:'id',to:'pd_prodid',ignore:true
  75. },{
  76. from:'pr_code',to:'pd_prodcode'
  77. },{
  78. from:'pr_detail',to:'pr_detail'
  79. },{
  80. from:'pr_spec',to:'pr_spec'
  81. },{
  82. from: 'pr_brand', to: 'pr_brand'
  83. },{
  84. from: 'pr_orispeccode', to: 'pr_orispeccode'
  85. },{
  86. from: 'pr_unit', to: 'pr_unit'
  87. }, {
  88. from:'pr_purcprice',to:'pd_lastprice'
  89. },{
  90. from:'pr_zxbzs',to:'pr_zxbzs'
  91. }],
  92. });
  93. }
  94. },
  95. 'dbfindtrigger[name=pd_whname]':{
  96. beforerender:function(f){
  97. Ext.apply(f,{
  98. dbfinds:[{
  99. from:'id',to:'pd_whid',ignore:true
  100. }, {
  101. from:'wh_code',to:'pd_whcode'
  102. }, {
  103. from:'wh_description',to:'pd_whname'
  104. }]
  105. }) ;
  106. },
  107. beforequery: function(f) {
  108. var me = this,
  109. viewModel = me.getViewModel();
  110. var s= f.ownerCt.ownerCmp.getSelectionModel(),
  111. id = s.lastSelected.id,
  112. record = s.store.getById(id),
  113. pd_prodid = record.get("pd_prodid");
  114. if(pd_prodid) {
  115. Ext.apply(f, {
  116. efaultCondition:"wh_statuscode='ENABLE' and (pw_prodid ="+pd_prodid+" OR IFNULL(pw_prodid,-1) = -1)",
  117. queryListMode:'OUT',
  118. dbColumns: [{
  119. text: "仓库ID",
  120. flex: 0,
  121. dataIndex: "id",
  122. hidden:true
  123. }, {
  124. text: "仓库编号",
  125. dataIndex: "wh_code",
  126. width: 150
  127. }, {
  128. text: "仓库名称",
  129. dataIndex: "wh_description",
  130. width: 200
  131. }, {
  132. text: "仓库类型",
  133. dataIndex: "wh_type",
  134. width: 110
  135. }, {
  136. text: "库存",
  137. dataIndex: "pw_onhand",
  138. width: 100,
  139. xtype: 'numbercolumn',
  140. renderer : function(v, m, r) {
  141. return saas.util.BaseUtil.numberFormat(v, 6, true);
  142. }
  143. }, {
  144. dataIndex: '',
  145. flex: 1
  146. }]
  147. });
  148. }else{
  149. Ext.apply(f, {
  150. efaultCondition:"wh_statuscode='ENABLE'",
  151. queryListMode:'',
  152. dbColumns: [{
  153. text: "仓库ID",
  154. flex: 0,
  155. dataIndex: "id",
  156. hidden:true
  157. }, {
  158. text: "仓库编号",
  159. dataIndex: "wh_code",
  160. width: 150
  161. }, {
  162. text: "仓库名称",
  163. dataIndex: "wh_description",
  164. width: 200
  165. }, {
  166. text: "仓库类型",
  167. dataIndex: "wh_type",
  168. width: 110
  169. }, {
  170. dataIndex: '',
  171. flex: 1
  172. }]
  173. });
  174. }
  175. },
  176. beforetriggerclick: function(f) {
  177. var me = this,
  178. viewModel = me.getViewModel();
  179. var s= f.ownerCt.ownerCmp.getSelectionModel(),
  180. id = s.lastSelected.id,
  181. record = s.store.getById(id),
  182. pd_prodid = record.get("pd_prodid");
  183. if(pd_prodid) {
  184. Ext.apply(f, {
  185. defaultCondition:"wh_statuscode='ENABLE' and (pw_prodid ="+pd_prodid+" OR IFNULL(pw_prodid,-1) = -1)",
  186. queryListMode:'OUT',
  187. dbColumns: [{
  188. text: "仓库ID",
  189. flex: 0,
  190. dataIndex: "id",
  191. hidden:true
  192. }, {
  193. text: "仓库编号",
  194. dataIndex: "wh_code",
  195. width: 150
  196. }, {
  197. text: "仓库名称",
  198. dataIndex: "wh_description",
  199. width: 200
  200. }, {
  201. text: "仓库类型",
  202. dataIndex: "wh_type",
  203. width: 110
  204. }, {
  205. text: "库存",
  206. dataIndex: "pw_onhand",
  207. width: 100,
  208. xtype: 'numbercolumn',
  209. renderer : function(v, m, r) {
  210. return saas.util.BaseUtil.numberFormat(v, 6, true);
  211. }
  212. }, {
  213. dataIndex: '',
  214. flex: 1
  215. }]
  216. });
  217. }else{
  218. Ext.apply(f, {
  219. defaultCondition:"wh_statuscode='ENABLE'",
  220. queryListMode:'',
  221. dbColumns: [{
  222. text: "仓库ID",
  223. flex: 0,
  224. dataIndex: "id",
  225. hidden:true
  226. }, {
  227. text: "仓库编号",
  228. dataIndex: "wh_code",
  229. width: 150
  230. }, {
  231. text: "仓库名称",
  232. dataIndex: "wh_description",
  233. width: 200
  234. }, {
  235. text: "仓库类型",
  236. dataIndex: "wh_type",
  237. width: 110
  238. }, {
  239. dataIndex: '',
  240. flex: 1
  241. }]
  242. });
  243. }
  244. }
  245. }
  246. });
  247. },
  248. /**
  249. * 生成退料单
  250. */
  251. turnMakeRet: function(){
  252. var me = this,
  253. form = me.getView(),
  254. id = form.getForm().findField(form._idField);
  255. form.setLoading(true);
  256. saas.util.BaseUtil.request({
  257. url: form._turnMakeRet + '/' + id.value,
  258. method: 'POST',
  259. })
  260. .then(function (localJson) {
  261. form.setLoading(false);
  262. if (localJson.success) {
  263. var intValue = localJson.data.id,
  264. codeValue = localJson.data.code,
  265. name = '外协退料';
  266. saas.util.BaseUtil.openTab('osmake-osmakereturn-formpanel', name + "(" + codeValue + ")", codeValue + intValue, {
  267. initId: intValue
  268. });
  269. saas.util.BaseUtil.showSuccessToast('转单成功');
  270. saas.util.FormUtil.loadData(form);
  271. }
  272. })
  273. .catch(function (e) {
  274. form.setLoading(false);
  275. saas.util.BaseUtil.showErrorToast('转单失败: ' + e.message);
  276. });
  277. },
  278. /**
  279. * 生成退料单
  280. */
  281. turnScrap: function(){
  282. var me = this,
  283. form = me.getView(),
  284. id = form.getForm().findField(form._idField);
  285. form.setLoading(true);
  286. saas.util.BaseUtil.request({
  287. url: form._turnScrap + '/' + id.value,
  288. method: 'POST',
  289. })
  290. .then(function (localJson) {
  291. form.setLoading(false);
  292. if (localJson.success) {
  293. var intValue = localJson.data.id,
  294. codeValue = localJson.data.code,
  295. name = '外协报废';
  296. saas.util.BaseUtil.openTab('osmake-osmakescrap-formpanel', name + "(" + codeValue + ")", codeValue + intValue, {
  297. initId: intValue
  298. });
  299. saas.util.BaseUtil.showSuccessToast('转单成功');
  300. saas.util.FormUtil.loadData(form);
  301. }
  302. })
  303. .catch(function (e) {
  304. form.setLoading(false);
  305. saas.util.BaseUtil.showErrorToast('转单失败: ' + e.message);
  306. });
  307. }
  308. });