FormPanelController.js 22 KB

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