ChildForm.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /**
  2. * Created by zhouy on 2018/10/18.
  3. */
  4. Ext.define('KitchenSink.view.binding.ChildForm', {
  5. extend: 'Ext.window.Window',
  6. xtype: 'document-kind-childwin',
  7. layout: 'fit',
  8. modal: true,
  9. width: 500,
  10. //工具类
  11. FormUtil: Ext.create('saas.util.FormUtil'),
  12. BaseUtil: Ext.create('saas.util.BaseUtil'),
  13. height: 260,
  14. listeners:{
  15. show:function(w){
  16. if(w.record){
  17. w.down('form').loadRecord(w.record);
  18. }
  19. }
  20. },
  21. initComponent:function(){
  22. var me=this;
  23. Ext.apply(me,{
  24. items:me.setFormItems()
  25. });
  26. me.callParent();
  27. },
  28. etc:{
  29. customerkind:{
  30. items:[{
  31. xtype:'hidden',
  32. name:'id'
  33. },{
  34. xtype:'textfield',
  35. name:'ck_name',
  36. allowBlank:false,
  37. fieldLabel:'客户类型'
  38. }]
  39. },
  40. vendorkind:{
  41. items:[{
  42. xtype:'hidden',
  43. name:'id'
  44. },{
  45. xtype:'textfield',
  46. name:'vk_name',
  47. allowBlank:false,
  48. fieldLabel:'供应商类型'
  49. }]
  50. },
  51. productkind:{
  52. items:[{
  53. xtype:'hidden',
  54. name:'id'
  55. },{
  56. xtype:'textfield',
  57. name:'pt_name',
  58. allowBlank:false,
  59. fieldLabel:'物料类型'
  60. }]
  61. },
  62. bankinformation:{
  63. items:[{
  64. xtype:'hidden',
  65. name:'id'
  66. },{
  67. xtype:'textfield',
  68. name:'bk_bankname',
  69. allowBlank:false,
  70. fieldLabel:'账户名称'
  71. },{
  72. xtype:'textfield',
  73. name:'bk_bankcode',
  74. allowBlank:false,
  75. fieldLabel:'账户编号'
  76. },{
  77. xtype:'numberfield',
  78. name:'bk_beginamount',
  79. allowBlank:false,
  80. fieldLabel:'期初金额'
  81. },{
  82. xtype:'numberfield',
  83. name:'bk_thisamount',
  84. allowBlank:false,
  85. fieldLabel:'当前金额'
  86. }]
  87. },
  88. productbrand:{
  89. items:[{
  90. xtype:'hidden',
  91. name:'id'
  92. },{
  93. xtype:'textfield',
  94. name:'pb_name',
  95. allowBlank:false,
  96. fieldLabel:'物料品牌'
  97. }]
  98. },
  99. productunit:{
  100. items:[{
  101. xtype:'hidden',
  102. name:'id'
  103. },{
  104. xtype:'textfield',
  105. name:'pu_name',
  106. allowBlank:false,
  107. fieldLabel:'计量单位'
  108. }]
  109. },
  110. inoutkind:{
  111. items:[{
  112. xtype:'hidden',
  113. name:'id'
  114. },{
  115. xtype:'textfield',
  116. name:'ft_name',
  117. allowBlank:false,
  118. fieldLabel:'类型'
  119. }]
  120. },
  121. address:{
  122. items:[{
  123. xtype:'hidden',
  124. name:'id'
  125. },{
  126. xtype:'textfield',
  127. name:'ad_address',
  128. allowBlank:false,
  129. fieldLabel:'地址详情'
  130. }]
  131. },
  132. warehouse:{
  133. items:[{
  134. xtype:'hidden',
  135. name:'id'
  136. },{
  137. xtype:'textfield',
  138. fieldLabel: '仓库编号',
  139. name: 'wh_code',
  140. allowBlank:false
  141. },{
  142. xtype:'textfield',
  143. fieldLabel: '仓库名称',
  144. name: 'wh_description',
  145. allowBlank:false
  146. },{
  147. readOnly:true,
  148. xtype:'textfield',
  149. fieldLabel: '仓库状态',
  150. name: 'wh_status',
  151. value:'已开启'
  152. },{
  153. xtype:'hidden',
  154. fieldLabel: '仓库状态码',
  155. name: 'wh_statuscode',
  156. value:'OPEN'
  157. }]
  158. },
  159. maxnumbers:{
  160. items:[{
  161. xtype:'hidden',
  162. name:'id'
  163. },{
  164. xtype:'textfield',
  165. fieldLabel: '单据Caller',
  166. name: 'mn_caller',
  167. allowBlank:false
  168. },{
  169. xtype:'textfield',
  170. fieldLabel: '单据前缀',
  171. name: 'mn_leadcode',
  172. allowBlank:false
  173. },{
  174. xtype:'combo',
  175. fieldLabel: '单据规则',
  176. name: 'mn_rule',
  177. displayField : "display",
  178. editable:false,
  179. hideTrigger : false,
  180. maxLength : 100.0,
  181. minValue : null,
  182. positiveNum : false,
  183. queryMode : "local",
  184. valueField : "value",
  185. store:{
  186. fields: ['display', 'value'],
  187. data : [
  188. {"display":"年月日", "value":'yyyymmdd'},
  189. {"display":"年月", "value":'yyyymm'}
  190. ]
  191. }
  192. },{
  193. xtype:'numberfield',
  194. hideTrigger : true,
  195. fieldLabel: '流水长度',
  196. name: 'mn_number',
  197. allowBlank:false
  198. }]
  199. }
  200. },
  201. setFormItems:function() {
  202. var me = this, kind = me.dataKind;
  203. var conf = {
  204. xtype: 'form',
  205. bodyPadding: 10,
  206. border: false,
  207. autoScroll:true,
  208. modelValidation: true,
  209. layout: {
  210. type: 'vbox',
  211. align: 'stretch'
  212. },
  213. defaults: {
  214. xtype: 'textfield'
  215. },
  216. buttons: [{
  217. text: '保存',
  218. formBind:true,
  219. handler: me.onSave,
  220. scope:me
  221. }, {
  222. text: '取消',
  223. handler: me.onCancel,
  224. scope:me
  225. }]
  226. };
  227. return Ext.apply(conf, me.etc[kind]);
  228. },
  229. onSave:function(){
  230. var belong = this.belong;
  231. var form=this.down('form');
  232. var combo = this._combo;
  233. var params = {};
  234. var names = belong.columns.map(column => column.dataIndex);
  235. Ext.Array.each(names,function(name) {
  236. if(name){
  237. var dataField = form.down('[name='+name+']');
  238. if(dataField&&dataField.value){
  239. params[name] = dataField.value;
  240. params._value = dataField.value;
  241. }
  242. }
  243. });
  244. var idField = form.down('[name='+belong.keyField+']');
  245. params[belong.keyField] = idField.value || 0;
  246. //保存接口
  247. this.BaseUtil.request({
  248. url: belong.reqUrl,
  249. params: JSON.stringify(params),
  250. method: 'POST',
  251. })
  252. .then(function(localJson) {
  253. if(localJson.success){
  254. showToast('保存成功');
  255. var grid = form.ownerCt._parent.lookup('document-kind-Grid');
  256. if(grid){
  257. grid.store.load();
  258. }
  259. if(combo){
  260. combo.store.load(function() {
  261. combo.setValue(params._value);
  262. });
  263. }
  264. form.ownerCt.close();
  265. }
  266. })
  267. .catch(function(res) {
  268. console.error(res);
  269. showToast('保存失败: ' + res.message);
  270. });
  271. },
  272. onCancel:function(){
  273. this.hide();
  274. }
  275. });