FormPanelController.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. Ext.define('saas.view.stock.make.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.stock-make-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. //放大镜赋值关系 以及 tpl模板
  8. 'dbfindtrigger[name=ma_whname]':{
  9. beforerender:function(f){
  10. Ext.apply(f,{
  11. dataUrl:'/api/document/warehouse/list',
  12. // dataUrl:'http://localhost:9480/warehouse/list',
  13. addXtype: 'other-warehouse',
  14. addTitle: '仓库资料',
  15. defaultCondition:"wh_statuscode='OPEN'",
  16. dbfinds:[{
  17. from:'id',to:'ma_whid',ignore:true
  18. },{
  19. from:'wh_code',to:'ma_whcode'
  20. },{
  21. from:'wh_description',to:'ma_whname'
  22. }],
  23. dbtpls:[{
  24. field:'wh_code',width:100
  25. },{
  26. field:'wh_description',width:100
  27. }],
  28. dbSearchFields:[{
  29. emptyText:'输入仓库编号或名称',
  30. xtype : "textfield",
  31. name : "wh_code",
  32. allowBlank : true,
  33. columnWidth : 0.25,
  34. getCondition:function(v){
  35. return "(upper(wh_code) like '%"+v.toUpperCase()+"%' or upper(wh_description) like '%"+v.toUpperCase()+"%')";
  36. }
  37. }],
  38. dbColumns:[{
  39. "text": "仓库ID",
  40. "flex": 0,
  41. "dataIndex": "id",
  42. "width": 0,
  43. "xtype": "",
  44. "items": null
  45. },{
  46. "text": "仓库编号",
  47. "flex": 1,
  48. "dataIndex": "wh_code",
  49. "width": 100,
  50. "xtype": "",
  51. "items": null
  52. }, {
  53. "text": "仓库名称",
  54. "flex": 1,
  55. "dataIndex": "wh_description",
  56. "xtype": "",
  57. "items": null
  58. }, {
  59. "text": "仓库类型",
  60. "flex": 1,
  61. "dataIndex": "wh_type",
  62. "xtype": "",
  63. "items": null
  64. }]
  65. }) ;
  66. }
  67. },
  68. //放大镜赋值关系 以及 tpl模板
  69. 'dbfindtrigger[name=mm_whname]':{
  70. beforerender:function(f){
  71. Ext.apply(f,{
  72. dataUrl:'/api/document/warehouse/list',
  73. // dataUrl:'http://localhost:9480/warehouse/list',
  74. addXtype: 'other-warehouse',
  75. addTitle: '仓库资料',
  76. defaultCondition:"wh_statuscode='OPEN'",
  77. dbfinds:[{
  78. from:'id',to:'mm_whid',ignore:true
  79. },{
  80. from:'wh_code',to:'mm_whcode'
  81. },{
  82. from:'wh_description',to:'mm_whname'
  83. }],
  84. dbtpls:[{
  85. field:'wh_code',width:100
  86. },{
  87. field:'wh_description',width:100
  88. }],
  89. dbSearchFields:[{
  90. emptyText:'输入仓库编号或名称',
  91. xtype : "textfield",
  92. name : "wh_code",
  93. allowBlank : true,
  94. columnWidth : 0.25,
  95. getCondition:function(v){
  96. return "(upper(wh_code) like '%"+v.toUpperCase()+"%' or upper(wh_description) like '%"+v.toUpperCase()+"%')";
  97. }
  98. }],
  99. dbColumns:[{
  100. "text": "仓库ID",
  101. "flex": 0,
  102. "dataIndex": "id",
  103. "width": 0,
  104. "xtype": "",
  105. "items": null
  106. },{
  107. "text": "仓库编号",
  108. "flex": 1,
  109. "dataIndex": "wh_code",
  110. "width": 100,
  111. "xtype": "",
  112. "items": null
  113. }, {
  114. "text": "仓库名称",
  115. "flex": 1,
  116. "dataIndex": "wh_description",
  117. "xtype": "",
  118. "items": null
  119. }, {
  120. "text": "仓库类型",
  121. "flex": 1,
  122. "dataIndex": "wh_type",
  123. "xtype": "",
  124. "items": null
  125. }]
  126. }) ;
  127. }
  128. },
  129. 'multidbfindtrigger[name=mm_prodcode]':{
  130. beforerender:function(f){
  131. Ext.apply(f,{
  132. //数据接口
  133. dataUrl:'/api/document/product/list',
  134. addXtype: 'document-product-formpanel',
  135. addTitle: '物料资料',
  136. //放大镜赋值设置
  137. dbfinds:[{
  138. from:'pr_code',to:'mm_prodcode'
  139. },{
  140. from:'id',to:'mm_prodid'
  141. },{
  142. from:'pr_detail',to:'pr_detail'
  143. },{
  144. from:'pr_spec',to:'pr_spec'
  145. },{
  146. from:'pr_unit',to:'pr_unit'
  147. }],
  148. //联想设置
  149. dbtpls:[{
  150. field:'pr_code',width:100
  151. },{
  152. field:'pr_detail',width:100
  153. },{
  154. field:'pr_spec',width:100
  155. }],
  156. defaultCondition:"pr_statuscode='OPEN'",
  157. //窗口字段设置
  158. dbSearchFields:[{
  159. emptyText:'输入物料编号、名称或规格',
  160. xtype : "textfield",
  161. name : "search",
  162. width: 200,
  163. getCondition: function(v) {
  164. return "(upper(pr_spec) like '%" + v.toUpperCase()+"%' or upper(pr_code) like '%"+v.toUpperCase()+"%' or upper(pr_detail) like '%"+v.toUpperCase()+"%')";
  165. },
  166. allowBlank : true,
  167. columnWidth : 0.25
  168. }],
  169. //窗口列设置
  170. dbColumns:[{
  171. "text": "物料ID",
  172. "hidden": true,
  173. "dataIndex": "id",
  174. }, {
  175. "text": "物料编号",
  176. "dataIndex": "pr_code",
  177. "width": 200,
  178. }, {
  179. "text": "物料名称",
  180. "width": 200,
  181. "dataIndex": "pr_detail",
  182. }, {
  183. "text": "规格",
  184. "dataIndex": "pr_spec",
  185. "width": 100,
  186. }, {
  187. "text": "单位",
  188. "dataIndex": "pr_spec",
  189. "width": 100,
  190. },{
  191. "text": "仓库id",
  192. "dataIndex": "pr_whid",
  193. "hidden": true,
  194. },{
  195. "text": "仓库编号",
  196. "dataIndex": "pr_whcode",
  197. "hidden": true,
  198. },{
  199. "text": "仓库",
  200. "dataIndex": "pr_whname",
  201. "width": 200,
  202. "hidden": true
  203. },{
  204. "text": "总库存数",
  205. "dataIndex": "po_onhand",
  206. "width": 100,
  207. xtype: 'numbercolumn',
  208. renderer : function(v) {
  209. var arr = (v + '.').split('.');
  210. var xr = (new Array(arr[1].length)).fill('0');
  211. var format = '0,000.' + xr.join();
  212. return Ext.util.Format.number(v, format);
  213. },
  214. align:'end'
  215. },{
  216. "text": "类型",
  217. "dataIndex": "pr_kind",
  218. "width": 100,
  219. },{
  220. "text": "型号",
  221. "dataIndex": "pr_orispeccode",
  222. "width": 100,
  223. },{
  224. "text": "品牌",
  225. "dataIndex": "pr_brand",
  226. "width": 100,
  227. },{
  228. "text": "供应商",
  229. "dataIndex": "pr_vendname",
  230. "width": 100,
  231. },{
  232. "text": "最小包装",
  233. "dataIndex": "pr_zxbzs",
  234. "width": 100,
  235. xtype: 'numbercolumn',
  236. align:'end'
  237. },{
  238. "text": "L/T",
  239. "dataIndex": "pr_leadtime",
  240. "width": 100,
  241. }]
  242. }) ;
  243. }
  244. },
  245. 'dbfindtrigger[name=ma_prodcode]':{
  246. beforerender:function(f){
  247. Ext.apply(f,{
  248. //数据接口
  249. dataUrl:'/api/document/bom/list',
  250. addXtype: 'document-bom-formpanel',
  251. addTitle: 'BOM资料',
  252. //放大镜赋值设置
  253. dbfinds:[{
  254. from:'bo_motherid',to:'ma_prodid'
  255. },{
  256. from:'bo_mothercode',to:'ma_prodcode'
  257. },{
  258. from:'bo_mothername',to:'ma_proddetail'
  259. },{
  260. from:'pr_spec',to:'ma_prodspec'
  261. },{
  262. from:'pr_unit',to:'ma_produnit'
  263. },{
  264. from:'bo_version',to:'ma_version'
  265. }],
  266. //联想设置
  267. dbtpls:[{
  268. field:'bo_mothercode',width:100
  269. },{
  270. field:'bo_mothername',width:100
  271. }],
  272. aftertrigger:function(f,record){
  273. me.getBomData(record.data.id)
  274. },
  275. defaultCondition:"bo_statuscode='OPEN'",
  276. //窗口字段设置
  277. dbSearchFields:[{
  278. emptyText:'输入BOM编号或名称',
  279. xtype : "textfield",
  280. name : "search",
  281. width: 200,
  282. getCondition: function(v) {
  283. return "(upper(bo_mothercode) like '%"+v.toUpperCase()+"%' or upper(bo_mothername) like '%"+v.toUpperCase()+"%')";
  284. },
  285. allowBlank : true,
  286. columnWidth : 0.25
  287. }],
  288. //窗口列设置
  289. dbColumns:[{
  290. "text": "物料ID",
  291. "hidden": true,
  292. "dataIndex": "id",
  293. }, {
  294. "text": "产品编号",
  295. "dataIndex": "bo_mothercode",
  296. "width": 200,
  297. }, {
  298. "text": "产品名称",
  299. "width": 200,
  300. "dataIndex": "bo_mothername",
  301. }, {
  302. "text": "产品规格",
  303. "width": 200,
  304. "dataIndex": "pr_spec",
  305. }, {
  306. "text": "版本",
  307. "width": 200,
  308. "dataIndex": "bo_version",
  309. }
  310. // ,{
  311. // "text": "规格",
  312. // "dataIndex": "pr_spec",
  313. // "width": 100,
  314. // }, {
  315. // "text": "单位",
  316. // "dataIndex": "pr_spec",
  317. // "width": 100,
  318. // },{
  319. // "text": "仓库id",
  320. // "dataIndex": "pr_whid",
  321. // "hidden": true,
  322. // },{
  323. // "text": "仓库编号",
  324. // "dataIndex": "pr_whcode",
  325. // "hidden": true,
  326. // },{
  327. // "text": "仓库",
  328. // "dataIndex": "pr_whname",
  329. // "width": 200,
  330. // },{
  331. // "text": "总库存数",
  332. // "dataIndex": "po_onhand",
  333. // "width": 100,
  334. // align:'end'
  335. // },{
  336. // "text": "类型",
  337. // "dataIndex": "pr_kind",
  338. // "width": 100,
  339. // },{
  340. // "text": "型号",
  341. // "dataIndex": "pr_orispeccode",
  342. // "width": 100,
  343. // },{
  344. // "text": "品牌",
  345. // "dataIndex": "pr_brand",
  346. // "width": 100,
  347. // },{
  348. // "text": "供应商",
  349. // "dataIndex": "pr_vendname",
  350. // "width": 100,
  351. // },{
  352. // "text": "最小包装",
  353. // "dataIndex": "pr_zxbzs",
  354. // "width": 100,
  355. // align:'end'
  356. // },{
  357. // "text": "L/T",
  358. // "dataIndex": "pr_leadtime",
  359. // "width": 100,
  360. // }
  361. ]
  362. }) ;
  363. }
  364. },
  365. //从表多选放大镜赋值关系 以及 tpl模板
  366. });
  367. },
  368. price_change:function() {
  369. var me = this,
  370. viewModel = me.getViewModel(),
  371. store = viewModel.get('detail0').detailStore;
  372. var sum_qty = store.sum('mm_price');
  373. viewModel.set('ma_price',sum_qty);
  374. },
  375. getBomData: function(v) {
  376. var me = this,
  377. form = me.getView(),
  378. viewModel = me.getViewModel(),
  379. store = viewModel.get('detail0').detailStore,
  380. loadData = new Array();;
  381. //请求bom资料
  382. saas.util.BaseUtil.request({
  383. url: form._getBomUrl+v,
  384. method: 'GET',
  385. })
  386. .then(function(localJson) {
  387. if(localJson.success){
  388. var data = localJson.data.items;
  389. Ext.Array.each(data, function(item, i) {
  390. loadData.push({
  391. mm_detno:item.bd_detno,
  392. mm_prodid:item.productDTO.id,
  393. mm_prodcode:item.productDTO.pr_code,
  394. mm_oneuseqty:item.bd_baseqty,
  395. pr_detail:item.productDTO.pr_detail,
  396. pr_spec:item.productDTO.pr_spec,
  397. pr_unit:item.productDTO.pr_unit,
  398. mm_repprodcode:item.bd_replace,
  399. mm_remark:item.bd_remark,
  400. mm_whid:item.productDTO.pr_whid,
  401. mm_whcode:item.productDTO.pr_whcode,
  402. mm_whname:item.productDTO.pr_whname
  403. })
  404. });
  405. store.loadData(loadData);
  406. }
  407. })
  408. .catch(function(res) {
  409. console.error(res);
  410. saas.util.BaseUtil.showToast('获取BOM资料失败: ' + res.message);
  411. });
  412. }
  413. });