MakeKindWindow.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /**
  2. * 制造类型编辑
  3. */
  4. Ext.define('make.view.make.makeKind.MakeKindWindow', {
  5. extend: 'Ext.window.Window',
  6. xtype: 'make-makekind-window',
  7. cls: 'x-window-dbfind ',
  8. viewModel: {
  9. data: {
  10. theKind: {
  11. },
  12. zeropricehide:false,//是否隐藏允许0单价
  13. }
  14. },
  15. controller: {
  16. handleSave: function () {
  17. var me = this,
  18. vm = me.getViewModel(),
  19. data = vm.get('theKind'),
  20. view = me.getView(),
  21. combo = view._combo;
  22. for( k in data) {
  23. if (Ext.isBoolean(data[k])) {
  24. data[k] = data[k] ? 1 : 0;
  25. }
  26. }
  27. if (data.id) {
  28. delete data.createTime,
  29. delete data.updateTime;
  30. } else {
  31. data.id = 0;
  32. data.mk_statuscode = 'ENABLE';
  33. data.mk_status = '已启用';
  34. }
  35. if(data.mk_makind == null || data.mk_makind== ''){
  36. data.mk_makind='MAKE';
  37. }
  38. view.mask('保存中');
  39. Ext.Ajax.post({
  40. url: '/api/make/kind/save',
  41. jsonData: data
  42. }).then(res => {
  43. view.unmask();
  44. if (res.success) {
  45. saas.util.BaseUtil.showSuccessToast('保存成功');
  46. view.close();
  47. view.onConfirm(view, data);
  48. var remotecombo = Ext.ComponentQuery.query("[xtype='remotecombo']");
  49. Ext.each(remotecombo, (i) => {
  50. if (i) {
  51. i.store.load(function () {
  52. //重新设置combo高度
  53. var count = i.store.getCount();
  54. var newHeight = count > 5 ? 248 - (i.hiddenBtn ? 50 : 0) : (33 * (count - 0.5) + (i.hiddenBtn ? 0 : 50));
  55. i.picker && i.picker.setHeight(newHeight);
  56. });
  57. }
  58. })
  59. if (combo) {
  60. combo.store.load(function () {
  61. typeof combo.setValue == 'function' && combo.setValue(data.mk_name);
  62. //重新设置combo高度
  63. var count = combo.store.getCount();
  64. var newHeight = count > 5 ? 248 - (combo.hiddenBtn ? 50 : 0) : (33 * (count - 0.5) + (combo.hiddenBtn ? 0 : 50));
  65. combo.picker && combo.picker.setHeight(newHeight);
  66. });
  67. }
  68. }
  69. }).catch(function (e) {
  70. view.unmask();
  71. saas.util.BaseUtil.showErrorToast('保存失败: ' + e.message);
  72. });
  73. },
  74. handleClose: function () {
  75. this.getView().close();
  76. }
  77. },
  78. title: '新增制造类型',
  79. modal: true,
  80. width: 500,
  81. bodyStyle: {
  82. margin: '10px 0 0 0'
  83. },
  84. bodyPadding: 20,
  85. layout: {
  86. type: 'vbox',
  87. pack: 'start',
  88. align: 'stretch'
  89. },
  90. initComponent: function () {
  91. var me = this;
  92. Ext.apply(me, {
  93. items: [{
  94. xtype: 'form',
  95. bodyPadding: '10 30 10 10',
  96. border: false,
  97. autoScroll: true,
  98. layout: 'column',
  99. defaults: {
  100. margin: '0 0 10 0',
  101. labelWidth: 110,
  102. columnWidth: 1
  103. },
  104. items: [
  105. {
  106. xtype: "hidden",
  107. name: "id",
  108. allowBlank: false,
  109. fieldLabel: 'ID',
  110. bind: '{theKind.id}'
  111. }, {
  112. xtype: "textfield",
  113. name: "mk_name",
  114. allowBlank: false,
  115. fieldLabel: '类型名称',
  116. bind: '{theKind.mk_name}',
  117. columnWidth: 0.7
  118. },{
  119. xtype: "checkbox",
  120. name: "mk_ifmrpkind",
  121. boxLabel: "默认类型",
  122. margin: '0 0 10 10',
  123. bind: '{theKind.mk_ifmrpkind}',
  124. columnWidth: 0.2,
  125. minWidth:80
  126. },{
  127. xtype: 'radiogroup',
  128. name: "mk_makind",
  129. fieldLabel: "生产类型",
  130. cls: 'x-check-group-alt',
  131. simpleValue: true,
  132. bind: '{theKind.mk_makind}',
  133. items: [
  134. {boxLabel: '自制', inputValue: 'MAKE', checked: true},
  135. {boxLabel: '外协', inputValue: 'OSMAKE'}
  136. ]
  137. },{
  138. xtype: "checkbox",
  139. name: "mk_allowover",
  140. boxLabel: "允许超工单发料",
  141. allowBlank: false,
  142. bind: '{theKind.mk_allowover}'
  143. },{
  144. xtype: "checkbox",
  145. name: "mk_overfinish",
  146. boxLabel: "允许超工单完工",
  147. allowBlank: false,
  148. bind: '{theKind.mk_overfinish}'
  149. }, {
  150. xtype: "checkbox",
  151. name: "mk_unsetfinish",
  152. boxLabel: "领料齐套才允许完工",
  153. bind: '{theKind.mk_unsetfinish}'
  154. }, {
  155. xtype: "checkbox",
  156. name: "mk_zeroprice",
  157. boxLabel: "允许0单价完工入库",
  158. bind:{
  159. value: '{theKind.mk_zeroprice}',
  160. hidden: '{zeropricehide}'
  161. }
  162. }, {
  163. xtype: "checkbox",
  164. name: "mk_autoend",
  165. boxLabel: "工单完工自动结案",
  166. bind: '{theKind.mk_autoend}'
  167. }, {
  168. xtype: "numberfield",
  169. name: "mk_reminddays",
  170. allowBlank: false,
  171. fieldLabel: '未结案提醒天数',
  172. minValue: 1,
  173. maxValue: 360,
  174. columnWidth: 0.7,
  175. bind: '{theKind.mk_reminddays}'
  176. }, {
  177. xtype: 'toolbar',
  178. items: ['->', {
  179. xtype: 'button',
  180. text: '保存',
  181. formBind: true,
  182. handler: 'handleSave',
  183. bind: {
  184. disabled: '{!form.typeId||!form.name}'
  185. }
  186. }, {
  187. xtype: 'button',
  188. text: '取消',
  189. handler: 'handleClose'
  190. }, '->']
  191. }],
  192. }]
  193. })
  194. me.callParent(arguments);
  195. },
  196. onConfirm: Ext.emptyFn
  197. });