ProjectEvaluation.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. Ext.define('erp.view.plm.project.ProjectEvaluation',{
  2. extend: 'Ext.Viewport',
  3. layout: 'fit',
  4. hideBorders: true,
  5. initComponent : function(){
  6. var me = this;
  7. Ext.apply(me, {
  8. items: [{
  9. layout: 'anchor',
  10. items: [{
  11. xtype: 'erpFormPanel',
  12. anchor: '100% 100%',
  13. saveUrl: 'plm/project/saveProjectEvaluation.action',
  14. deleteUrl: 'plm/project/deleteProjectEvaluation.action',
  15. updateUrl: 'plm/project/updateProjectEvaluation.action',
  16. auditUrl: 'plm/project/auditProjectEvaluation.action',
  17. resAuditUrl: 'plm/project/resAuditProjectEvaluation.action',
  18. submitUrl: 'plm/project/submitProjectEvaluation.action',
  19. resSubmitUrl: 'plm/project/resSubmitProjectEvaluation.action',
  20. getIdUrl: 'common/getId.action?seq=ProjectEvaluation_SEQ',
  21. keyField: 'pe_id',
  22. statuscodeField: 'pe_statuscode',
  23. getItemsAndButtons: function(form, url, param){
  24. var datalistId = getUrlParam('datalistId');
  25. var type=getUrlParam('pe_type');
  26. if(datalistId||type||param.condition){
  27. if(type){
  28. param.caller='ProjectEvaluation'+type;
  29. caller=param.caller;
  30. param.condition ='pe_id='+getUrlParam('pe_id');
  31. }
  32. form.FormUtil.getItemsAndButtons(this, 'common/singleFormItems.action', this.params || param);
  33. }else{
  34. Ext.create('Ext.window.Window', {
  35. autoShow: true,
  36. width: 300,
  37. height: 200,
  38. id:'projectWin',
  39. layout: 'anchor',
  40. items: [{
  41. anchor:'100% 100%',
  42. xtype:'form',
  43. buttonAlign : 'center',
  44. items:[{
  45. xtype: 'combo',
  46. id:'type',
  47. width:280,
  48. fieldLabel: '项目类别',
  49. store: Ext.create('Ext.data.Store', {
  50. autoLoad: true,
  51. fields: ["display", "value"],
  52. data:[{value: "STANDARD", display: "标准方案"}, {value: "CUSTOM", display: "定制方案"}]
  53. }),
  54. queryMode: 'local',
  55. displayField: 'display',
  56. valueField: 'value',
  57. allowBlank:false,
  58. selectOnFocus:true,
  59. editable:'false',
  60. value:'STANDARD'
  61. },{
  62. xtype:'dbfindtrigger',
  63. width:280,
  64. id:'templet',
  65. fieldLabel:'方案模板编号',
  66. name: "templet"
  67. }]
  68. }],
  69. buttonAlign: 'center',
  70. buttons: [{
  71. text: '确定',
  72. handler: function(b) {
  73. var type=Ext.getCmp('type').value;
  74. var templet=Ext.getCmp('templet').value;
  75. if(!type){
  76. showError('请选择项目类别');
  77. return;
  78. }else if(type=='STANDARD'&&!templet){
  79. showError('请选择方案模板');
  80. return;
  81. }
  82. if(templet){
  83. if(type=='STANDARD'){
  84. this.caller='ProjectEvaluationSTANDARD';
  85. }else{
  86. this.caller='ProjectEvaluationCUSTOM';
  87. }
  88. var param = {caller: this.caller || caller, condition:"pe_tempcode='"+templet+"' and pe_type='TEMPLET'", _noc: (getUrlParam('_noc') || this._noc)};
  89. me.setLoading(true);
  90. Ext.Ajax.request({//拿到form的items
  91. url : basePath + url,
  92. params: param,
  93. method : 'post',
  94. callback : function(options, success, response){
  95. me.setLoading(false);
  96. Ext.getCmp('projectWin').close();
  97. if (!response) return;
  98. var res = new Ext.decode(response.responseText);
  99. if(res.exceptionInfo != null){
  100. showError(res.exceptionInfo);return;
  101. }
  102. form.fo_id = res.fo_id;
  103. form.fo_keyField = res.keyField;
  104. form.tablename = res.tablename;//表名
  105. if(res.keyField){//主键
  106. form.keyField = res.keyField;
  107. }
  108. if(res.statusField){//状态
  109. form.statusField = res.statusField;
  110. }
  111. if(res.statuscodeField){//状态码
  112. form.statuscodeField = res.statuscodeField;
  113. }
  114. if(res.codeField){//Code
  115. form.codeField = res.codeField;
  116. }
  117. form.fo_detailMainKeyField = res.fo_detailMainKeyField;//从表外键字段
  118. var grids = Ext.ComponentQuery.query('gridpanel');
  119. //如果该页面只有一个form,而且form字段少于8个,则布局改变
  120. if(!form.fixedlayout && !form.minMode && grids.length == 0 && res.items.length <= 8){
  121. Ext.each(res.items, function(item){
  122. item.columnWidth = 0.5;
  123. });
  124. form.layout = 'column';
  125. }
  126. if((res.items.length>0.097*window.innerWidth && window.innerWidth<=1150)){
  127. Ext.each(res.items, function(item){
  128. form.layout='column';
  129. //若根据分辨率直接获取宽度会导致 有时不能占满整行
  130. item.width=window.innerWidth*(item.columnWidth)-item.columnWidth*4*10;
  131. });
  132. }
  133. //data&items
  134. var items = form.setItems(form, res.items, res.data, res.limits,type, {
  135. labelColor: res.necessaryFieldColor
  136. });
  137. form.add(items);
  138. //title
  139. if(res.title && res.title != ''){
  140. form.setTitle(res.title);
  141. var _tt = res.title;
  142. if(form.codeField) {
  143. var _c = form.down('#' + form.codeField);
  144. if( _c && !Ext.isEmpty(_c.value) )
  145. _tt += '(' + _c.value + ')';
  146. }
  147. }
  148. if(!form._nobutton) form.FormUtil.setButtons(form,'erpSaveButton#erpCloseButton');
  149. form.fireEvent('afterload', form);
  150. }
  151. });
  152. }else{
  153. var param = {caller:'ProjectEvaluationCUSTOM', condition:'', _noc: (getUrlParam('_noc') || this._noc)};
  154. form.FormUtil.getItemsAndButtons(form, 'common/singleFormItems.action', this.params || param);
  155. Ext.getCmp('projectWin').close();
  156. }
  157. }
  158. }, {
  159. text: '取消',
  160. handler: function(b) {
  161. b.ownerCt.ownerCt.close();
  162. }
  163. }]
  164. });
  165. }
  166. },
  167. setItems: function(form, items, data, limits, type,necessaryCss){
  168. var me=this,edit = !form.readOnly,hasData = true,limitArr = new Array();
  169. if(limits != null && limits.length > 0) {//权限外字段
  170. limitArr = Ext.Array.pluck(limits, 'lf_field');
  171. }
  172. if (data) {
  173. data = Ext.decode(data);
  174. data.pe_id='';
  175. data.pe_statuscode='ENTERING';
  176. data.pe_status='在录入';
  177. data.pe_type=type;
  178. data.pe_recorderid=em_id;
  179. data.pe_recordername=em_name;
  180. var oDate = new Date(); //实例一个时间对象;
  181. data.pe_recorddate=oDate;
  182. data.pe_auditer='';
  183. data.pe_auditdate='';
  184. } else {
  185. hasData = false;
  186. }
  187. var bool = 'a';
  188. if(items.length > 110&&items.length <=190){
  189. bool = 'b';
  190. }else if(items.length>190){
  191. bool = 'c';
  192. }
  193. Ext.each(items, function(item){
  194. if(screen.width < 1280){//根据屏幕宽度,调整列显示宽度
  195. if(item.columnWidth > 0 && item.columnWidth <= 0.25){
  196. item.columnWidth = 1/3;
  197. } else if(item.columnWidth > 0.25 && item.columnWidth <= 0.5){
  198. item.columnWidth = 2/3;
  199. } else if(item.columnWidth >= 1){
  200. item.columnWidth = 1;
  201. }
  202. } else {
  203. if(item.columnWidth > 0.25 && item.columnWidth < 0.5){
  204. item.columnWidth = 1/3;
  205. } else if(item.columnWidth > 0.5 && item.columnWidth < 0.75){
  206. item.columnWidth = 2/3;
  207. }
  208. }
  209. if(!item.allowBlank && item.fieldLabel && necessaryCss.labelColor) {
  210. item.labelStyle = 'color:#' + necessaryCss.labelColor;
  211. item.fieldStyle = 'background:#FFFAFA;color:#515151;';
  212. }
  213. if(item.readOnly) {
  214. item.fieldStyle = 'background:#e0e0e0;';
  215. }
  216. if(item.renderfn){
  217. if(contains(item.renderfn, ':', true)){
  218. var args = new Array();
  219. Ext.each(item.renderfn.split(':'), function(a, index){
  220. if(index == 0){
  221. renderName = a;
  222. } else {
  223. args.push(a);
  224. }
  225. });
  226. }
  227. me[renderName](item,args);
  228. }
  229. if(item.name != null) {
  230. if(item.name == form.statusField){//状态加特殊颜色
  231. item.fieldStyle = item.fieldStyle + ';font-weight:bold;';
  232. } else if(item.name == form.statuscodeField){//状态码字段强制隐藏
  233. item.xtype = 'hidden';
  234. }
  235. }
  236. if(item.xtype == 'hidden') {
  237. item.columnWidth = 0;
  238. item.margin = '0';
  239. }
  240. if(item.xtype == 'checkbox') {
  241. item.focusCls = '';
  242. }
  243. if(item.maskRe!=null){
  244. item.maskRe=new RegExp(item.regex);
  245. }
  246. if (hasData) {
  247. item.value = data[item.name];
  248. if(item.secondname){//针对合并型的字段MultiField
  249. item.secondvalue = data[item.secondname];
  250. }
  251. if(!edit){
  252. form.readOnly = true;
  253. item.fieldStyle = item.fieldStyle + ';background:#f1f1f1;';
  254. item.readOnly = true;
  255. }
  256. if(item.xtype == 'checkbox'){
  257. item.checked = Math.abs(item.value || 0) == 1;
  258. item.fieldStyle = '';
  259. }
  260. }
  261. form.FormUtil.setItemWidth(form, items);
  262. if(limitArr.length > 0 && Ext.Array.contains(limitArr, item.name)) {
  263. item.hidden = true;
  264. }
  265. if(item.html&&item.name == null&&item.value==''){
  266. }else{
  267. if(bool == 'b') {
  268. item.columnWidth = item.columnWidth*0.83;
  269. }
  270. if(bool == 'c') {
  271. item.columnWidth = item.columnWidth*0.85;
  272. }
  273. }
  274. });
  275. return items;
  276. }
  277. }]
  278. }]
  279. });
  280. me.callParent(arguments);
  281. }
  282. });