ChildForm.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. xtype:'textfield',
  148. fieldLabel: '仓库类型',
  149. name: 'wh_type',
  150. allowBlank:false
  151. },{
  152. readOnly:true,
  153. xtype:'textfield',
  154. fieldLabel: '仓库状态',
  155. name: 'wh_status',
  156. value:'已开启'
  157. },{
  158. xtype:'hidden',
  159. fieldLabel: '仓库状态码',
  160. name: 'wh_statuscode',
  161. value:'OPEN'
  162. }]
  163. },
  164. maxnumbers:{
  165. items:[{
  166. xtype:'hidden',
  167. name:'id'
  168. },{
  169. xtype:'textfield',
  170. fieldLabel: '单据名称',
  171. name: 'mn_caller',
  172. allowBlank:false,
  173. editable:false,
  174. readOnly:true
  175. },{
  176. xtype:'textfield',
  177. fieldLabel: '单据前缀',
  178. name: 'mn_leadcode',
  179. allowBlank:false
  180. },{
  181. xtype:'combo',
  182. fieldLabel: '单据规则',
  183. name: 'mn_rule',
  184. displayField : "display",
  185. editable:false,
  186. hideTrigger : false,
  187. maxLength : 100.0,
  188. minValue : null,
  189. positiveNum : false,
  190. queryMode : "local",
  191. valueField : "value",
  192. store:{
  193. fields: ['display', 'value'],
  194. data : [
  195. {"display":"年月日", "value":'yyyymmdd'},
  196. {"display":"年月", "value":'yyyymm'}
  197. ]
  198. }
  199. },{
  200. xtype:'numberfield',
  201. hideTrigger : true,
  202. fieldLabel: '流水长度',
  203. name: 'mn_number',
  204. allowBlank:false
  205. }]
  206. }
  207. },
  208. setFormItems:function() {
  209. var me = this, kind = me.dataKind;
  210. var conf = {
  211. xtype: 'form',
  212. bodyPadding: 10,
  213. border: false,
  214. autoScroll:true,
  215. modelValidation: true,
  216. layout: {
  217. type: 'vbox',
  218. align: 'stretch'
  219. },
  220. defaults: {
  221. xtype: 'textfield'
  222. },
  223. buttons: [{
  224. text: '保存',
  225. formBind:true,
  226. handler: me.onSave,
  227. scope:me
  228. }, {
  229. text: '取消',
  230. handler: me.onCancel,
  231. scope:me
  232. }]
  233. };
  234. return Ext.apply(conf, me.etc[kind]);
  235. },
  236. onSave:function(){
  237. var belong = this.belong;
  238. var form=this.down('form');
  239. var combo = this._combo;
  240. var params = {};
  241. var names = belong.columns.map(column => column.dataIndex);
  242. Ext.Array.each(names,function(name) {
  243. if(name){
  244. var dataField = form.down('[name='+name+']');
  245. if(dataField&&dataField.value){
  246. params[name] = dataField.value;
  247. params._value = dataField.value;
  248. }
  249. }
  250. });
  251. var idField = form.down('[name='+belong.keyField+']');
  252. params[belong.keyField] = idField.value || 0;
  253. //保存接口
  254. this.BaseUtil.request({
  255. url: belong.reqUrl,
  256. params: JSON.stringify(params),
  257. method: 'POST',
  258. })
  259. .then(function(localJson) {
  260. if(localJson.success){
  261. showToast('保存成功');
  262. var grid = form.ownerCt._parent.lookup('document-kind-Grid');
  263. if(grid){
  264. grid.store.load();
  265. }
  266. if(combo){
  267. combo.store.load(function() {
  268. combo.setValue(params._value);
  269. });
  270. }
  271. form.ownerCt.close();
  272. }
  273. })
  274. .catch(function(res) {
  275. console.error(res);
  276. showToast('保存失败: ' + res.message);
  277. });
  278. },
  279. onCancel:function(){
  280. this.hide();
  281. }
  282. });