FeatureValueView.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.bom.FeatureValueView', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'core.form.Panel','pm.bom.FeatureProduct','core.grid.Panel2','core.toolbar.Toolbar',
  9. 'core.button.Save','core.button.Add','core.button.Upload','core.button.LoadFeature',
  10. 'core.button.Submit','core.button.ResSubmit','core.button.Audit','core.button.ResAudit',
  11. 'core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
  12. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger','core.form.YnField'
  13. ],
  14. init:function(){
  15. var me = this;
  16. this.control({
  17. 'erpGridPanel2': {
  18. // afterrender: function(grid){
  19. // alert(grid.getStore().getCount());
  20. // },
  21. itemclick: function(selModel, record){
  22. // console.log(Ext.getCmp('grid'));
  23. if(!Ext.getCmp('grid').readOnly){
  24. this.onGridItemClick(selModel, record);
  25. }
  26. }
  27. },
  28. 'erpCloseButton':{
  29. afterrender:function(btn){
  30. var value=Ext.getCmp('pr_code').value;
  31. if(value) me.loadFeature(value);
  32. }
  33. },
  34. 'field[name=pr_code]': {
  35. afterrender: function(f){
  36. var condition = getUrlParam('condition');
  37. if(condition != null && condition != ''){
  38. var data = condition.split(' AND ');
  39. Ext.getCmp('id').setValue(data[0].split('IS')[1]);
  40. Ext.getCmp('pr_code').setValue(data[1].split('IS')[1]);
  41. }
  42. },
  43. change: function(f){
  44. if(f!=null){
  45. me.loadFeature(f.value);
  46. } else {
  47. Ext.getCmp('grid').removeAll();
  48. }
  49. }
  50. },
  51. 'button[id=expand]': {
  52. click: function(btn){
  53. var pr_code=Ext.getCmp('pr_code').value;
  54. var url="jsps/pm/bom/BOMStructQuery.jsp?whoami=BOMStruct!Struct!Query";
  55. var condition="";
  56. if(pr_code){
  57. condition+="pr_codeIS'"+pr_code+"'";
  58. }
  59. me.FormUtil.onAdd('BOMStruct'+ pr_code, 'BOM多级展开', url+"&condition="+condition);
  60. }
  61. },
  62. 'button[id=find]':{
  63. click: function(btn){
  64. var bo_id=Ext.getCmp('pr_bomid');
  65. //me.FormUtil.onAdd('locationBOM' + id, 'BOM多级展开', 'jsps/common/BOMTree.jsp.jsp?whoami=BOMStruct!Struct!Query&condition=bo_idIS'+bo_id+' AND bo_mothercodeIS'+Ext.getCmp('pr_code').value);
  66. me.FormUtil.onAdd('BOMStruct'+ bo_id, 'BOM树形查看', "jsps/make/bom/BOMTree.jsp?whoami=BOMStruct!Struct!Query&condition=bo_idIS"+bo_id+" AND bo_mothercodeIS"+Ext.getCmp('pr_code').value );
  67. }
  68. }
  69. });
  70. },
  71. onGridItemClick: function(selModel, record){//grid行选择
  72. this.GridUtil.onGridItemClick(selModel, record);
  73. },
  74. getForm: function(btn){
  75. return btn.ownerCt.ownerCt;
  76. },
  77. loadFeature: function(num){
  78. var me = this;
  79. var specdescription = null;
  80. Ext.getCmp('pr_refno').setValue(me.getDescription("product","pr_refno","pr_code='" + Ext.getCmp('pr_code').value + "'"));
  81. specdescription=me.getDescription("product","pr_specdescription","pr_code='" + Ext.getCmp('pr_code').value + "'");
  82. if (specdescription=="" && specdescription==null){
  83. showError('没有可查看的特征值');
  84. return;
  85. }
  86. Ext.Ajax.request({//拿到grid的columns
  87. url : basePath + "common/loadNewGridStore.action",
  88. params: {
  89. caller: 'ProdFeature',
  90. condition: "pf_prodcode='" + Ext.getCmp('pr_refno').value + "'"
  91. },
  92. method : 'post',
  93. callback : function(options,success,response){
  94. var res = new Ext.decode(response.responseText);
  95. if(res.exceptionInfo){
  96. showError(res.exceptionInfo);return;
  97. }
  98. var data = res.data;
  99. var fpd = [];
  100. if(data != null && data.length > 0){
  101. Ext.each(data, function(d, index){
  102. var da = {
  103. pf_detno : d.pf_detno,
  104. pf_fecode : d.pf_fecode,
  105. pf_fename : d.fe_name
  106. };
  107. var des = me.toArrays(null,null,null,specdescription);
  108. if(des != '' && des != null){//获取之前保存记录
  109. Ext.each(des[0], function(de, i){
  110. if(de==d.pf_fecode){
  111. da.fd_valuecode = des[1][i];
  112. var os = me.getFdValues(de, des[1][i]);
  113. da.fd_value=os[0];
  114. da.fd_spec=os[1];
  115. da.fd_remark=os[2];
  116. }
  117. });
  118. }
  119. fpd[index] = da;
  120. });
  121. Ext.getCmp('grid').store.loadData(fpd);
  122. } else {
  123. showError('没有可载入的特征');return;
  124. }
  125. }
  126. });
  127. },
  128. toArrays:function(tn, field, con, description){
  129. var code = [];
  130. var valuecode = [];
  131. var result = [code,valuecode];
  132. var data = description==null ? this.getDescription(tn, field, con) : description;
  133. if(data != null && data != ''){
  134. var da = data.split('|');
  135. Ext.each(da, function(d, index){
  136. code[index] = d.split(':')[0];
  137. valuecode[index] = d.split(':')[1];
  138. });
  139. }
  140. return result;
  141. },
  142. getFdValues: function(code, valuecode){//根据特征项code和特征值码获取特征值
  143. var result = '';
  144. Ext.Ajax.request({
  145. url : basePath + "pm/bom/getFields.action",
  146. params: {
  147. tablename: 'FeatureDetail',
  148. field: ['fd_value','fd_spec','fd_remark'],//'fd_value',
  149. condition: "fd_code='" + code + "' and fd_valuecode='" + valuecode + "'"
  150. },
  151. method : 'post',
  152. async: false,
  153. callback : function(options,success,response){
  154. var res = new Ext.decode(response.responseText);
  155. if(res.exceptionInfo){
  156. showError(res.exceptionInfo);return;
  157. }
  158. if(res.success){
  159. result = res.data;
  160. }
  161. }
  162. });
  163. console.log(result);
  164. return result;
  165. },
  166. getDescription: function(tn, field, con){
  167. var des = '';
  168. Ext.Ajax.request({//拿到grid的columns
  169. url : basePath + "pm/bom/getDescription.action",
  170. params: {
  171. tablename: tn,
  172. field: field,
  173. condition: con
  174. },
  175. method : 'post',
  176. async: false,
  177. callback : function(options,success,response){
  178. var res = new Ext.decode(response.responseText);
  179. if(res.exceptionInfo){
  180. showError(res.exceptionInfo);return;
  181. }
  182. if(res.success && res.description != null){
  183. console.log(res.description);
  184. des = res.description;
  185. }
  186. }
  187. });
  188. return des;
  189. },
  190. getFdValue: function(code, valuecode){//根据特征项code和特征值码获取特征值
  191. var result = '';
  192. Ext.Ajax.request({
  193. url : basePath + "pm/bom/getDescription.action",
  194. params: {
  195. tablename: 'FeatureDetail',
  196. field: 'fd_value',
  197. condition: "fd_code='" + code + "' and fd_valuecode='" + valuecode + "'"
  198. },
  199. method : 'post',
  200. async: false,
  201. callback : function(options,success,response){
  202. var res = new Ext.decode(response.responseText);
  203. if(res.exceptionInfo){
  204. showError(res.exceptionInfo);return;
  205. }
  206. if(res.success){
  207. result = res.description;
  208. }
  209. }
  210. });
  211. console.log(result);
  212. return result;
  213. },
  214. getFdSpec: function(code, valuecode){//根据特征项code和特征值码获取特征值
  215. var result = '';
  216. Ext.Ajax.request({
  217. url : basePath + "pm/bom/getDescription.action",
  218. params: {
  219. tablename: 'FeatureDetail',
  220. field: 'fd_spec',
  221. condition: "fd_code='" + code + "' and fd_valuecode='" + valuecode + "'"
  222. },
  223. method : 'post',
  224. async: false,
  225. callback : function(options,success,response){
  226. var res = new Ext.decode(response.responseText);
  227. if(res.exceptionInfo){
  228. showError(res.exceptionInfo);return;
  229. }
  230. if(res.success){
  231. result = res.description;
  232. }
  233. }
  234. });
  235. console.log(result);
  236. return result;
  237. }
  238. });