FormController.js 16 KB

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