FormController.js 11 KB

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