FormController.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. Ext.define('saas.view.document.bom.FormController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.document-bom-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. //放大镜赋值关系 以及 tpl模板
  8. 'dbfindtrigger[name=bo_mothercode]':{
  9. beforerender:function(f){
  10. Ext.apply(f,{
  11. dataUrl:'/api/document/product/list',
  12. addXtype: 'document-product-formpanel',
  13. addTitle: '物料资料',
  14. dbfinds:[
  15. {
  16. from:'pr_code',to:'bo_mothercode'
  17. }, {
  18. from:'pr_detail',to:'bo_mothername'
  19. }, {
  20. from:'pr_spec',to:'pr_spec'
  21. }, {
  22. from:'id',to:'bo_motherid',ignore:true
  23. }],
  24. dbtpls:[{
  25. field:'pr_code',width:100
  26. },{
  27. field:'pr_detail',width:100
  28. }],
  29. defaultCondition: "pr_statuscode='OPEN'",
  30. dbSearchFields:[{
  31. emptyText:'输入物料编号、名称或规格',
  32. xtype : "textfield",
  33. name : "search",
  34. width: 200,
  35. getCondition: function(v) {
  36. return "(upper(pr_spec) like '%" + v.toUpperCase()+"%' or upper(pr_code) like '%"+v.toUpperCase()+"%' or upper(pr_detail) like '%"+v.toUpperCase()+"%')";
  37. },
  38. allowBlank : true,
  39. columnWidth : 0.25
  40. }],
  41. dbColumns:[{
  42. "text": "物料ID",
  43. "hidden": true,
  44. "dataIndex": "id",
  45. }, {
  46. "text": "物料编号",
  47. "dataIndex": "pr_code",
  48. "width": 200,
  49. }, {
  50. "text": "物料名称",
  51. "width": 200,
  52. "dataIndex": "pr_detail",
  53. }, {
  54. "text": "规格",
  55. "dataIndex": "pr_spec",
  56. "width": 100,
  57. }, {
  58. "text": "单位",
  59. "dataIndex": "pr_unit",
  60. "width": 100,
  61. },{
  62. "text": "仓库id",
  63. "dataIndex": "pr_whid",
  64. "hidden": true,
  65. },{
  66. "text": "仓库编号",
  67. "dataIndex": "pr_whcode",
  68. "hidden": true,
  69. },{
  70. "text": "仓库",
  71. "dataIndex": "pr_whname",
  72. "width": 200,
  73. },{
  74. "text": "总库存数",
  75. "dataIndex": "po_onhand",
  76. "width": 100,
  77. xtype: 'numbercolumn',
  78. align:'end'
  79. },{
  80. "text": "类型",
  81. "dataIndex": "pr_kind",
  82. "width": 100,
  83. },{
  84. "text": "型号",
  85. "dataIndex": "pr_orispeccode",
  86. "width": 100,
  87. },{
  88. "text": "品牌",
  89. "dataIndex": "pr_brand",
  90. "width": 100,
  91. },{
  92. "text": "供应商",
  93. "dataIndex": "pr_vendname",
  94. "width": 100,
  95. },{
  96. "text": "最小包装",
  97. "dataIndex": "pr_zxbzs",
  98. "width": 100,
  99. align:'end'
  100. },{
  101. "text": "L/T",
  102. "dataIndex": "pr_leadtime",
  103. "width": 100,
  104. }]
  105. }) ;
  106. }
  107. },
  108. //从表多选放大镜赋值关系 以及 tpl模板
  109. 'multidbfindtrigger[name=bd_soncode]':{
  110. beforerender:function(f){
  111. Ext.apply(f,{
  112. //数据接口
  113. dataUrl: '/api/document/product/list',
  114. addXtype: 'document-product-formpanel',
  115. addTitle: '物料资料',
  116. //放大镜赋值设置
  117. dbfinds:[{
  118. from:'pr_code',to:'bd_soncode'
  119. },{
  120. from:'pr_detail',to:'pr_detail'
  121. },{
  122. from:'pr_spec',to:'pr_spec'
  123. },{
  124. from:'pr_unit',to:'bd_unit'
  125. },{
  126. from:'id',to:'bd_sonid',ignore:true
  127. }],
  128. //联想设置
  129. dbtpls:[{
  130. field:'pr_code',width:100
  131. },{
  132. field:'pr_detail',width:100
  133. }],
  134. defaultCondition: "pr_statuscode='OPEN'",
  135. dbSearchFields:[{
  136. emptyText:'输入物料编号、名称或规格',
  137. width: 200,
  138. xtype : "textfield",
  139. name : "search",
  140. allowBlank : true,
  141. columnWidth : 0.25,
  142. getCondition:function(v){
  143. return "(upper(pr_code) like '%" + v.toUpperCase() + "%' or upper(pr_detail) like '%"+ v.toUpperCase() +"%' or upper(pr_spec) like '%"+ v.toUpperCase() +"%')";
  144. }
  145. }],
  146. //窗口列设置
  147. dbColumns:[{
  148. "text": "物料ID",
  149. "hidden": true,
  150. "dataIndex": "id",
  151. }, {
  152. "text": "物料编号",
  153. "dataIndex": "pr_code",
  154. "width": 200,
  155. }, {
  156. "text": "物料名称",
  157. "width": 200,
  158. "dataIndex": "pr_detail",
  159. }, {
  160. "text": "规格",
  161. "dataIndex": "pr_spec",
  162. "width": 100,
  163. }, {
  164. "text": "单位",
  165. "dataIndex": "pr_unit",
  166. "width": 100,
  167. }, {
  168. "text": "最新采购单价",
  169. "dataIndex": "pr_purcprice",
  170. "width": 0,
  171. xtype: 'numbercolumn',
  172. align:'end'
  173. },{
  174. "text": "仓库id",
  175. "dataIndex": "pr_whid",
  176. "hidden": true,
  177. },{
  178. "text": "仓库编号",
  179. "dataIndex": "pr_whcode",
  180. "hidden": true,
  181. },{
  182. "text": "仓库名称",
  183. "dataIndex": "pr_whname",
  184. "width": 200,
  185. },{
  186. "text": "总库存数",
  187. "dataIndex": "po_onhand",
  188. "width": 100,
  189. xtype: 'numbercolumn',
  190. align:'end'
  191. },{
  192. "text": "类型",
  193. "dataIndex": "pr_kind",
  194. "width": 100,
  195. },{
  196. "text": "型号",
  197. "dataIndex": "pr_orispeccode",
  198. "width": 100,
  199. },{
  200. "text": "品牌",
  201. "dataIndex": "pr_brand",
  202. "width": 100,
  203. },{
  204. "text": "供应商",
  205. "dataIndex": "pr_vendname",
  206. "width": 100,
  207. },{
  208. "text": "最小包装",
  209. "dataIndex": "pr_zxbzs",
  210. "width": 100,
  211. align:'end'
  212. },{
  213. "text": "L/T",
  214. "dataIndex": "pr_leadtime",
  215. "width": 100,
  216. }]
  217. }) ;
  218. }
  219. },
  220. 'multidbfindtrigger[name=bd_replace]':{
  221. beforerender:function(f){
  222. Ext.apply(f,{
  223. //数据接口
  224. dataUrl: '/api/document/product/list',
  225. addXtype: 'document-product-formpanel',
  226. addTitle: '物料资料',
  227. //放大镜赋值设置
  228. dbfinds:[
  229. {
  230. from:'pr_code',to:'bd_replace'
  231. },{
  232. from:'pr_detail',to:'pr_detail'
  233. },{
  234. from:'pr_spec',to:'pr_spec'
  235. },{
  236. from:'pr_unit',to:'pr_unit'
  237. }],
  238. //联想设置
  239. dbtpls:[{
  240. field:'pr_code',width:100
  241. },{
  242. field:'pr_detail',width:100
  243. }],
  244. defaultCondition: "pr_statuscode='OPEN'",
  245. dbSearchFields:[{
  246. emptyText:'输入物料编号、名称或规格',
  247. width: 200,
  248. xtype : "textfield",
  249. name : "search",
  250. allowBlank : true,
  251. columnWidth : 0.25,
  252. getCondition:function(v){
  253. return "(upper(pr_code) like '%" + v.toUpperCase() + "%' or upper(pr_detail) like '%"+ v.toUpperCase() +"%' or upper(pr_spec) like '%"+ v.toUpperCase() +"%')";
  254. }
  255. }],
  256. //窗口列设置
  257. dbColumns:[{
  258. "text": "物料ID",
  259. "hidden": true,
  260. "dataIndex": "id",
  261. }, {
  262. "text": "物料编号",
  263. "dataIndex": "pr_code",
  264. "width": 200,
  265. }, {
  266. "text": "物料名称",
  267. "width": 200,
  268. "dataIndex": "pr_detail",
  269. }, {
  270. "text": "规格",
  271. "dataIndex": "pr_spec",
  272. "width": 100,
  273. }, {
  274. "text": "单位",
  275. "dataIndex": "pr_unit",
  276. "width": 100,
  277. }, {
  278. "text": "最新采购单价",
  279. "dataIndex": "pr_purcprice",
  280. "width": 0,
  281. xtype: 'numbercolumn',
  282. },{
  283. "text": "仓库id",
  284. "dataIndex": "pr_whid",
  285. "hidden": true,
  286. },{
  287. "text": "仓库编号",
  288. "dataIndex": "pr_whcode",
  289. "hidden": true,
  290. },{
  291. "text": "仓库",
  292. "dataIndex": "pr_whname",
  293. "width": 200,
  294. },{
  295. "text": "总库存数",
  296. "dataIndex": "po_onhand",
  297. xtype: 'numbercolumn',
  298. "width": 100,
  299. },{
  300. "text": "类型",
  301. "dataIndex": "pr_kind",
  302. "width": 100,
  303. },{
  304. "text": "型号",
  305. "dataIndex": "pr_orispeccode",
  306. "width": 100,
  307. },{
  308. "text": "品牌",
  309. "dataIndex": "pr_brand",
  310. "width": 100,
  311. },{
  312. "text": "供应商",
  313. "dataIndex": "pr_vendname",
  314. "width": 100,
  315. },{
  316. "text": "最小包装",
  317. "dataIndex": "pr_zxbzs",
  318. "width": 100,
  319. xtype: 'numbercolumn',
  320. },{
  321. "text": "L/T",
  322. "dataIndex": "pr_leadtime",
  323. "width": 100,
  324. }]
  325. }) ;
  326. }
  327. }
  328. });
  329. },
  330. auditBtnClick: function() {
  331. var me = this,
  332. form = me.getView(),
  333. statusCodeField = form._statusCodeField,
  334. viewModel = me.getViewModel(),
  335. status = viewModel.data[statusCodeField];
  336. status == 'OPEN' ? me.unAudit() : me.audit();
  337. },
  338. audit: function(){
  339. var me = this,
  340. form = this.getView(),
  341. viewModel = me.getViewModel();
  342. me.BaseUtil.request({
  343. url: form._openUrl+'/'+viewModel.data.id,
  344. params: '',
  345. method: 'POST',
  346. })
  347. .then(function(localJson) {
  348. if(localJson.success){
  349. form.initId = localJson.data.id;
  350. form.FormUtil.loadData(form);
  351. //viewModel.set('base.editable', false);
  352. showToast('启用成功');
  353. }
  354. })
  355. .catch(function(res) {
  356. console.error(res);
  357. showToast('启用失败: ' + res.message);
  358. });
  359. },
  360. unAudit: function() {
  361. var me = this,
  362. form = this.getView(),
  363. viewModel = me.getViewModel();
  364. me.BaseUtil.request({
  365. url: form._closeUrl+'/'+viewModel.data.id,
  366. params: '',
  367. method: 'POST',
  368. })
  369. .then(function(localJson) {
  370. if(localJson.success){
  371. form.initId = localJson.data.id;
  372. form.FormUtil.loadData(form);
  373. // viewModel.set('base.editable', false);
  374. showToast('关闭成功');
  375. }
  376. })
  377. .catch(function(res) {
  378. showToast('关闭失败: ' + res.message);
  379. });
  380. }
  381. });