FormPanelController.js 21 KB

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