FormController.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  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. 'multidbfindtrigger[name=bd_soncode]':{
  9. beforerender:function(f){
  10. Ext.apply(f,{
  11. //数据接口
  12. dataUrl: '/api/document/product/list',
  13. addXtype: 'document-product-formpanel',
  14. addTitle: '物料资料',
  15. //放大镜赋值设置
  16. dbfinds:[{
  17. from:'pr_code',to:'bd_soncode'
  18. },{
  19. from:'pr_detail',to:'pr_detail'
  20. },{
  21. from:'pr_spec',to:'pr_spec'
  22. },{
  23. from:'pr_unit',to:'bd_unit'
  24. }],
  25. //联想设置
  26. dbtpls:[{
  27. field:'pr_code',width:100
  28. },{
  29. field:'pr_detail',width:100
  30. }],
  31. defaultCondition: "pr_statuscode='OPEN'",
  32. dbSearchFields:[{
  33. emptyText:'输入物料编号、名称或规格',
  34. width: 200,
  35. xtype : "textfield",
  36. name : "search",
  37. allowBlank : true,
  38. columnWidth : 0.25,
  39. getCondition:function(v){
  40. return "(upper(pr_code) like '%" + v.toUpperCase() + "%' or upper(pr_detail) like '%"+ v.toUpperCase() +"%' or upper(pr_spec) like '%"+ v.toUpperCase() +"%')";
  41. }
  42. }],
  43. //窗口列设置
  44. dbColumns:[{
  45. "text": "物料ID",
  46. "hidden": true,
  47. "dataIndex": "id",
  48. }, {
  49. "text": "物料编号",
  50. "dataIndex": "pr_code",
  51. "width": 200,
  52. }, {
  53. "text": "物料名称",
  54. "width": 200,
  55. "dataIndex": "pr_detail",
  56. }, {
  57. "text": "规格",
  58. "dataIndex": "pr_spec",
  59. "width": 100,
  60. }, {
  61. "text": "单位",
  62. "dataIndex": "pr_unit",
  63. "width": 100,
  64. }, {
  65. "text": "最新采购单价",
  66. "dataIndex": "pr_purcprice",
  67. "width": 0,
  68. align:'right'
  69. },{
  70. "text": "仓库id",
  71. "dataIndex": "pr_whid",
  72. "hidden": true,
  73. },{
  74. "text": "仓库编号",
  75. "dataIndex": "pr_whcode",
  76. "hidden": true,
  77. },{
  78. "text": "仓库名称",
  79. "dataIndex": "pr_whname",
  80. "width": 200,
  81. },{
  82. "text": "总库存数",
  83. "dataIndex": "po_onhand",
  84. "width": 100,
  85. align:'right'
  86. },{
  87. "text": "类型",
  88. "dataIndex": "pr_kind",
  89. "width": 100,
  90. },{
  91. "text": "型号",
  92. "dataIndex": "pr_orispeccode",
  93. "width": 100,
  94. },{
  95. "text": "品牌",
  96. "dataIndex": "pr_brand",
  97. "width": 100,
  98. },{
  99. "text": "供应商",
  100. "dataIndex": "pr_vendname",
  101. "width": 100,
  102. },{
  103. "text": "最小包装",
  104. "dataIndex": "pr_zxbzs",
  105. "width": 100,
  106. align:'right'
  107. },{
  108. "text": "L/T",
  109. "dataIndex": "pr_leadtime",
  110. "width": 100,
  111. }]
  112. }) ;
  113. }
  114. },
  115. 'multidbfindtrigger[name=bd_replace]':{
  116. beforerender:function(f){
  117. Ext.apply(f,{
  118. //数据接口
  119. dataUrl: '/api/document/product/list',
  120. addXtype: 'document-product-formpanel',
  121. addTitle: '物料资料',
  122. //放大镜赋值设置
  123. dbfinds:[
  124. {
  125. from:'pr_code',to:'bd_replace'
  126. },{
  127. from:'pr_detail',to:'pr_detail'
  128. },{
  129. from:'pr_spec',to:'pr_spec'
  130. },{
  131. from:'pr_unit',to:'pr_unit'
  132. }],
  133. //联想设置
  134. dbtpls:[{
  135. field:'pr_code',width:100
  136. },{
  137. field:'pr_detail',width:100
  138. }],
  139. defaultCondition: "pr_statuscode='OPEN'",
  140. dbSearchFields:[{
  141. emptyText:'输入物料编号、名称或规格',
  142. width: 200,
  143. xtype : "textfield",
  144. name : "search",
  145. allowBlank : true,
  146. columnWidth : 0.25,
  147. getCondition:function(v){
  148. return "(upper(pr_code) like '%" + v.toUpperCase() + "%' or upper(pr_detail) like '%"+ v.toUpperCase() +"%' or upper(pr_spec) like '%"+ v.toUpperCase() +"%')";
  149. }
  150. }],
  151. //窗口列设置
  152. dbColumns:[{
  153. "text": "物料ID",
  154. "hidden": true,
  155. "dataIndex": "id",
  156. }, {
  157. "text": "物料编号",
  158. "dataIndex": "pr_code",
  159. "width": 200,
  160. }, {
  161. "text": "物料名称",
  162. "width": 200,
  163. "dataIndex": "pr_detail",
  164. }, {
  165. "text": "规格",
  166. "dataIndex": "pr_spec",
  167. "width": 100,
  168. }, {
  169. "text": "单位",
  170. "dataIndex": "pr_unit",
  171. "width": 100,
  172. }, {
  173. "text": "最新采购单价",
  174. "dataIndex": "pr_purcprice",
  175. "width": 0,
  176. },{
  177. "text": "仓库id",
  178. "dataIndex": "pr_whid",
  179. "hidden": true,
  180. },{
  181. "text": "仓库编号",
  182. "dataIndex": "pr_whcode",
  183. "hidden": true,
  184. },{
  185. "text": "仓库",
  186. "dataIndex": "pr_whname",
  187. "width": 200,
  188. },{
  189. "text": "总库存数",
  190. "dataIndex": "po_onhand",
  191. "width": 100,
  192. },{
  193. "text": "类型",
  194. "dataIndex": "pr_kind",
  195. "width": 100,
  196. },{
  197. "text": "型号",
  198. "dataIndex": "pr_orispeccode",
  199. "width": 100,
  200. },{
  201. "text": "品牌",
  202. "dataIndex": "pr_brand",
  203. "width": 100,
  204. },{
  205. "text": "供应商",
  206. "dataIndex": "pr_vendname",
  207. "width": 100,
  208. },{
  209. "text": "最小包装",
  210. "dataIndex": "pr_zxbzs",
  211. "width": 100,
  212. },{
  213. "text": "L/T",
  214. "dataIndex": "pr_leadtime",
  215. "width": 100,
  216. }]
  217. }) ;
  218. }
  219. }
  220. });
  221. },
  222. auditBtnClick: function() {
  223. var me = this,
  224. form = me.getView(),
  225. statusCodeField = form._statusCodeField,
  226. viewModel = me.getViewModel(),
  227. status = viewModel.data[statusCodeField];
  228. status == 'OPEN' ? me.unAudit() : me.audit();
  229. },
  230. audit: function(){
  231. var me = this,
  232. form = this.getView(),
  233. viewModel = me.getViewModel();
  234. me.BaseUtil.request({
  235. url: form._openUrl+'/'+viewModel.data.id,
  236. params: '',
  237. method: 'POST',
  238. })
  239. .then(function(localJson) {
  240. if(localJson.success){
  241. form.initId = localJson.data.id;
  242. form.FormUtil.loadData(form);
  243. //viewModel.set('base.editable', false);
  244. showToast('启用成功');
  245. }
  246. })
  247. .catch(function(res) {
  248. console.error(res);
  249. showToast('启用失败: ' + res.message);
  250. });
  251. },
  252. unAudit: function() {
  253. var me = this,
  254. form = this.getView(),
  255. viewModel = me.getViewModel();
  256. me.BaseUtil.request({
  257. url: form._closeUrl+'/'+viewModel.data.id,
  258. params: '',
  259. method: 'POST',
  260. })
  261. .then(function(localJson) {
  262. if(localJson.success){
  263. form.initId = localJson.data.id;
  264. form.FormUtil.loadData(form);
  265. // viewModel.set('base.editable', false);
  266. showToast('关闭成功');
  267. }
  268. })
  269. .catch(function(res) {
  270. console.log(res);
  271. showToast('关闭失败: ' + res.message);
  272. });
  273. }
  274. });