FormPanelController.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  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:'pd_whcode',width:100
  25. },{
  26. field:'pd_whname',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:'pd_whcode',width:100
  86. },{
  87. field:'pd_whname',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_spec'
  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. },{
  203. "text": "总库存数",
  204. "dataIndex": "po_onhand",
  205. "width": 100,
  206. xtype: 'numbercolumn',
  207. align:'end'
  208. },{
  209. "text": "类型",
  210. "dataIndex": "pr_kind",
  211. "width": 100,
  212. },{
  213. "text": "型号",
  214. "dataIndex": "pr_orispeccode",
  215. "width": 100,
  216. },{
  217. "text": "品牌",
  218. "dataIndex": "pr_brand",
  219. "width": 100,
  220. },{
  221. "text": "供应商",
  222. "dataIndex": "pr_vendname",
  223. "width": 100,
  224. },{
  225. "text": "最小包装",
  226. "dataIndex": "pr_zxbzs",
  227. "width": 100,
  228. xtype: 'numbercolumn',
  229. align:'end'
  230. },{
  231. "text": "L/T",
  232. "dataIndex": "pr_leadtime",
  233. "width": 100,
  234. }]
  235. }) ;
  236. }
  237. },
  238. 'dbfindtrigger[name=ma_prodcode]':{
  239. beforerender:function(f){
  240. Ext.apply(f,{
  241. //数据接口
  242. dataUrl:'/api/document/bom/list',
  243. addXtype: 'document-bom-formpanel',
  244. addTitle: 'BOM资料',
  245. //放大镜赋值设置
  246. dbfinds:[{
  247. from:'bo_motherid',to:'ma_prodid'
  248. },{
  249. from:'bo_mothercode',to:'ma_prodcode'
  250. },{
  251. from:'bo_mothername',to:'ma_proddetail'
  252. },{
  253. from:'pr_spec',to:'ma_prodspec'
  254. },{
  255. from:'bo_version',to:'ma_version'
  256. }],
  257. //联想设置
  258. dbtpls:[{
  259. field:'bo_mothercode',width:100
  260. },{
  261. field:'bo_mothername',width:100
  262. }],
  263. aftertrigger:function(f,record){
  264. me.getBomData(record.data.id)
  265. },
  266. defaultCondition:"bo_statuscode='OPEN'",
  267. //窗口字段设置
  268. dbSearchFields:[{
  269. emptyText:'输入BOM编号或名称',
  270. xtype : "textfield",
  271. name : "search",
  272. width: 200,
  273. getCondition: function(v) {
  274. return "(upper(bo_mothercode) like '%"+v.toUpperCase()+"%' or upper(bo_mothername) like '%"+v.toUpperCase()+"%')";
  275. },
  276. allowBlank : true,
  277. columnWidth : 0.25
  278. }],
  279. //窗口列设置
  280. dbColumns:[{
  281. "text": "物料ID",
  282. "hidden": true,
  283. "dataIndex": "id",
  284. }, {
  285. "text": "产品编号",
  286. "dataIndex": "bo_mothercode",
  287. "width": 200,
  288. }, {
  289. "text": "产品名称",
  290. "width": 200,
  291. "dataIndex": "bo_mothername",
  292. }, {
  293. "text": "产品规格",
  294. "width": 200,
  295. "dataIndex": "pr_spec",
  296. }, {
  297. "text": "版本",
  298. "width": 200,
  299. "dataIndex": "bo_version",
  300. }
  301. // ,{
  302. // "text": "规格",
  303. // "dataIndex": "pr_spec",
  304. // "width": 100,
  305. // }, {
  306. // "text": "单位",
  307. // "dataIndex": "pr_spec",
  308. // "width": 100,
  309. // },{
  310. // "text": "仓库id",
  311. // "dataIndex": "pr_whid",
  312. // "hidden": true,
  313. // },{
  314. // "text": "仓库编号",
  315. // "dataIndex": "pr_whcode",
  316. // "hidden": true,
  317. // },{
  318. // "text": "仓库",
  319. // "dataIndex": "pr_whname",
  320. // "width": 200,
  321. // },{
  322. // "text": "总库存数",
  323. // "dataIndex": "po_onhand",
  324. // "width": 100,
  325. // align:'end'
  326. // },{
  327. // "text": "类型",
  328. // "dataIndex": "pr_kind",
  329. // "width": 100,
  330. // },{
  331. // "text": "型号",
  332. // "dataIndex": "pr_orispeccode",
  333. // "width": 100,
  334. // },{
  335. // "text": "品牌",
  336. // "dataIndex": "pr_brand",
  337. // "width": 100,
  338. // },{
  339. // "text": "供应商",
  340. // "dataIndex": "pr_vendname",
  341. // "width": 100,
  342. // },{
  343. // "text": "最小包装",
  344. // "dataIndex": "pr_zxbzs",
  345. // "width": 100,
  346. // align:'end'
  347. // },{
  348. // "text": "L/T",
  349. // "dataIndex": "pr_leadtime",
  350. // "width": 100,
  351. // }
  352. ]
  353. }) ;
  354. }
  355. },
  356. //从表多选放大镜赋值关系 以及 tpl模板
  357. 'multidbfindtrigger[name=pd_prodcode]':{
  358. beforerender:function(f){
  359. Ext.apply(f,{
  360. //数据接口
  361. dataUrl:'/api/document/product/list',
  362. addXtype: 'document-product-formpanel',
  363. addTitle: '物料资料',
  364. //放大镜赋值设置
  365. dbfinds:[{
  366. from:'pr_code',to:'pd_prodcode'
  367. },{
  368. from:'pr_unit',to:'pd_unit'
  369. }],
  370. //联想设置
  371. dbtpls:[{
  372. field:'pr_code',width:100
  373. },{
  374. field:'pr_detail',width:100
  375. }],
  376. defaultCondition:"pr_statuscode='OPEN'",
  377. //窗口字段设置
  378. dbSearchFields:[{
  379. emptyText:'输入物料编号、名称或规格',
  380. xtype : "textfield",
  381. name : "search",
  382. width: 200,
  383. getCondition: function(v) {
  384. return "(upper(pr_spec) like '%" + v.toUpperCase()+"%' or upper(pr_code) like '%"+v.toUpperCase()+"%' or upper(pr_detail) like '%"+v.toUpperCase()+"%')";
  385. },
  386. allowBlank : true,
  387. columnWidth : 0.25
  388. }],
  389. //窗口列设置
  390. dbColumns:[{
  391. "text": "物料ID",
  392. "hidden": true,
  393. "dataIndex": "id",
  394. }, {
  395. "text": "物料编号",
  396. "dataIndex": "pr_code",
  397. "width": 200,
  398. }, {
  399. "text": "物料名称",
  400. "width": 200,
  401. "dataIndex": "pr_detail",
  402. }, {
  403. "text": "规格",
  404. "dataIndex": "pr_spec",
  405. "width": 100,
  406. }, {
  407. "text": "单位",
  408. "dataIndex": "pr_unit",
  409. "width": 100,
  410. },{
  411. "text": "仓库id",
  412. "dataIndex": "pr_whid",
  413. "hidden": true,
  414. },{
  415. "text": "仓库编号",
  416. "dataIndex": "pr_whcode",
  417. "hidden": true,
  418. },{
  419. "text": "仓库",
  420. "dataIndex": "pr_whname",
  421. "width": 200,
  422. },{
  423. "text": "总库存数",
  424. "dataIndex": "po_onhand",
  425. "width": 100,
  426. align: 'end'
  427. },{
  428. "text": "类型",
  429. "dataIndex": "pr_kind",
  430. "width": 100,
  431. },{
  432. "text": "型号",
  433. "dataIndex": "pr_orispeccode",
  434. "width": 100,
  435. },{
  436. "text": "品牌",
  437. "dataIndex": "pr_brand",
  438. "width": 100,
  439. },{
  440. "text": "供应商",
  441. "dataIndex": "pr_vendname",
  442. "width": 100,
  443. },{
  444. "text": "最小包装",
  445. "dataIndex": "pr_zxbzs",
  446. "width": 100,
  447. align: 'end'
  448. },{
  449. "text": "L/T",
  450. "dataIndex": "pr_leadtime",
  451. "width": 100,
  452. }]
  453. }) ;
  454. }
  455. }
  456. });
  457. },
  458. price_change:function() {
  459. var me = this,
  460. viewModel = me.getViewModel(),
  461. store = viewModel.get('detail0').detailStore;
  462. var sum_qty = store.sum('mm_price');
  463. viewModel.set('ma_price',sum_qty);
  464. },
  465. getBomData: function(v) {
  466. var me = this,
  467. form = me.getView(),
  468. viewModel = me.getViewModel(),
  469. store = viewModel.get('detail0').detailStore,
  470. loadData = new Array();;
  471. //请求bom资料
  472. form.BaseUtil.request({
  473. url: form._getBomUrl+v,
  474. method: 'GET',
  475. })
  476. .then(function(localJson) {
  477. if(localJson.success){
  478. var data = localJson.data.items;
  479. Ext.Array.each(data, function(item, i) {
  480. loadData.push({
  481. mm_detno:item.bd_detno,
  482. mm_prodid:item.productDTO.id,
  483. mm_prodcode:item.productDTO.pr_code,
  484. mm_oneuseqty:item.bd_baseqty,
  485. pr_detail:item.productDTO.pr_detail,
  486. pr_spec:item.productDTO.pr_spec,
  487. pr_unit:item.productDTO.pr_unit,
  488. mm_repprodcode:item.bd_replace,
  489. mm_remark:item.bd_remark,
  490. mm_whid:item.productDTO.pr_whid,
  491. mm_whcode:item.productDTO.pr_whcode,
  492. mm_whname:item.productDTO.pr_whname
  493. })
  494. });
  495. console.log(loadData);
  496. store.loadData(loadData);
  497. }
  498. })
  499. .catch(function(res) {
  500. console.error(res);
  501. showToast('获取BOM资料失败: ' + res.message);
  502. });
  503. }
  504. });