FormController.js 11 KB

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