FormPanel.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. Ext.define('saas.view.document.bom.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'document-bom-formpanel',
  4. controller: 'document-bom-formpanel',
  5. viewModel: 'document-bom-formpanel',
  6. caller:'Bom',
  7. //字段属性
  8. _title:'客户资料',
  9. _idField: 'id',
  10. _codeField: 'bo_mothercode',
  11. _statusField: 'bo_status',
  12. _statusCodeField: 'bo_statuscode',
  13. _readUrl:basePath+'document/bom/read/',
  14. _saveUrl:basePath+'document/bom/save',
  15. _openUrl:basePath+'document/bom/open',
  16. _closeUrl:basePath+'document/bom/close',
  17. _deleteUrl:basePath+'document/bom/delete/',
  18. initId:0,
  19. defaultItems: [{
  20. xtype: 'hidden',
  21. name: 'id',
  22. fieldLabel: 'id',
  23. allowBlank: true,
  24. columnWidth: 0.25
  25. },{
  26. xtype: 'hidden',
  27. name: 'bo_motherid',
  28. fieldLabel: '母件id',
  29. allowBlank: true,
  30. columnWidth: 0.25
  31. },{
  32. xtype: 'textfield',
  33. name: 'bo_mothername',
  34. fieldLabel: 'BOM名称',
  35. allowBlank: false,
  36. columnWidth: 0.25
  37. },{
  38. xtype: 'textfield',
  39. name: 'bo_mothercode',
  40. fieldLabel: 'BOM编号',
  41. allowBlank: true,
  42. columnWidth: 0.25
  43. },{
  44. xtype: 'textfield',
  45. name: 'bo_status',
  46. fieldLabel: 'BOM状态',
  47. allowBlank: true,
  48. columnWidth: 0.25
  49. },{
  50. xtype: 'hidden',
  51. name: 'bo_statuscode',
  52. fieldLabel: '状态码',
  53. allowBlank: true,
  54. columnWidth: 0.25
  55. },{
  56. format : "Y-m-d",
  57. xtype : "datefield",
  58. name : "createTime",
  59. fieldLabel : "创建时间",
  60. allowBlank : true,
  61. columnWidth : 0.25
  62. },{
  63. format : "Y-m-d",
  64. xtype : "datefield",
  65. name : "updateTime",
  66. fieldLabel : "更新时间",
  67. allowBlank : true,
  68. columnWidth : 0.25
  69. }, {
  70. xtype : "detailGridField",
  71. detnoColumn: 'bd_detno',
  72. storeModel:'saas.model.document.bomdetail',
  73. deleteDetailUrl:basePath+'document/bom/deleteDetail/',
  74. columns : [
  75. {
  76. text : "ID",
  77. dataIndex : "id",
  78. width : 0,
  79. xtype : "numbercolumn"
  80. },
  81. {
  82. text : "关联ID",
  83. dataIndex : "bd_bomid",
  84. width : 0,
  85. xtype : "numbercolumn"
  86. },
  87. {
  88. text : "子件编号",
  89. editor : {
  90. xtype : "textfield"
  91. },
  92. dataIndex : "bd_soncode",
  93. width : 120.0,
  94. xtype : "",
  95. items : null
  96. },
  97. {
  98. text : "单位",
  99. editor : {
  100. xtype : "textfield"
  101. },
  102. dataIndex : "bd_unit",
  103. width : 120.0,
  104. xtype : "",
  105. items : null
  106. },
  107. {
  108. text : "单位用量",
  109. editor : {
  110. xtype : "textfield"
  111. },
  112. dataIndex : "bd_baseqty",
  113. width : 120.0,
  114. xtype : "",
  115. items : null
  116. },
  117. {
  118. text : "替代料",
  119. editor : {
  120. xtype : "textfield"
  121. },
  122. dataIndex : "bd_replace",
  123. width : 120.0,
  124. xtype : "",
  125. items : null
  126. }]
  127. }],
  128. /**
  129. * 一些初始化viewModel的方法
  130. */
  131. initViewModel: function() {
  132. var me = this,
  133. codeField = me._codeField,
  134. statusField = me._statusField,
  135. statusCodeField = me._statusCodeField,
  136. viewModel = me.getViewModel();
  137. viewModel.set(codeField, '');
  138. viewModel.set('createTime', new Date());
  139. viewModel.set('updateTime', new Date());
  140. if(statusCodeField) {
  141. var o = {};
  142. o['auditBtnText'] = {
  143. bind: '{' + statusCodeField + '}',
  144. get: function(value) {
  145. viewModel.set(statusField, value == 'OPEN' ? '启用' : '禁用');
  146. return value == 'OPEN' ? '禁用' : '启用'
  147. }
  148. };
  149. viewModel.setFormulas(o);
  150. viewModel.set(statusCodeField, "OPEN");
  151. }else {
  152. viewModel.set('auditBtnText', "禁用");
  153. }
  154. }
  155. });