FormPanel.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. Ext.define('saas.view.document.customer.FormPanel', {
  2. extend: 'saas.view.core.form.FormPanel',
  3. xtype: 'document-customer-formpanel',
  4. controller: 'document-customer-formpanel',
  5. viewModel: 'document-customer-formpanel',
  6. caller:'Customer',
  7. //字段属性
  8. _title:'客户资料',
  9. _idField: 'id',
  10. _codeField: 'cu_code',
  11. _statusField: 'cu_status',
  12. _statusCodeField: 'cu_statuscode',
  13. _readUrl:basePath+'ducument/customer/read/',
  14. _saveUrl:basePath+'ducument/customer/save',
  15. _openUrl:basePath+'ducument/customer/open',
  16. _closeUrl:basePath+'ducument/customer/close',
  17. _deleteUrl:basePath+'ducument/customer/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: 'textfield',
  27. name: 'cu_name',
  28. fieldLabel: '客户名称',
  29. allowBlank: false,
  30. columnWidth: 0.25
  31. },{
  32. xtype: 'textfield',
  33. name: 'cu_code',
  34. fieldLabel: '客户编号',
  35. allowBlank: true,
  36. columnWidth: 0.25
  37. },{
  38. xtype: 'textfield',
  39. name: 'cu_status',
  40. fieldLabel: '状态',
  41. allowBlank: true,
  42. columnWidth: 0.25
  43. },{
  44. xtype: 'hidden',
  45. name: 'cu_statuscode',
  46. fieldLabel: '状态码',
  47. allowBlank: true,
  48. columnWidth: 0.25
  49. },{
  50. xtype : "remotecombo",
  51. storeUrl:basePath+'ducument/customerkind/getCombo',
  52. name : "cu_type",
  53. fieldLabel : "客户类型",
  54. allowBlank : true,
  55. queryMode: 'local',
  56. displayField: 'display',
  57. valueField: 'value',
  58. columnWidth : 0.25,
  59. etc:{
  60. customerkind:{
  61. keyField:'id',
  62. dataField:'ck_name',
  63. reqUrl:basePath+'ducument/customerkind/save',
  64. delUrl:basePath+'ducument/customerkind/delete'
  65. }
  66. },
  67. addHandler:function(b){
  68. var form = this.ownerCmp.ownerCt;
  69. this.dialog = form.getController().getView().add({
  70. xtype: 'document-kind-childwin',
  71. bind: {
  72. title: '新增客户类型'
  73. },
  74. dataKind:'customerkind',
  75. belong:this.ownerCmp.etc['customerkind'],
  76. _parent:form,
  77. record:null,
  78. session: true
  79. });
  80. this.dialog.show();
  81. }
  82. },{
  83. format : "Y-m-d",
  84. xtype : "datefield",
  85. name : "createTime",
  86. fieldLabel : "创建时间",
  87. allowBlank : true,
  88. columnWidth : 0.25
  89. },{
  90. format : "Y-m-d",
  91. xtype : "datefield",
  92. name : "cu_begindate",
  93. fieldLabel : "期初日期",
  94. allowBlank : true,
  95. columnWidth : 0.25
  96. },{
  97. xtype : "numberfield",
  98. hideTrigger:true,
  99. name : "cu_beginaramount",
  100. fieldLabel : "期初应收",
  101. allowBlank : true,
  102. columnWidth : 0.25
  103. },{
  104. xtype : "numberfield",
  105. hideTrigger:true,
  106. name : "cu_beginprerecamount",
  107. fieldLabel : "期初预收",
  108. allowBlank : true,
  109. columnWidth : 0.25
  110. },{
  111. xtype : "numberfield",
  112. hideTrigger:true,
  113. name : "cu_promisedays",
  114. fieldLabel : "承付天数",
  115. allowBlank : true,
  116. columnWidth : 0.25
  117. },{
  118. xtype : "numberfield",
  119. name : "cu_taxrate",
  120. fieldLabel : "税率",
  121. allowBlank : true,
  122. columnWidth : 0.25
  123. },{
  124. xtype : "numberfield",
  125. name : "cu_ta",
  126. fieldLabel : "应收款余额",
  127. allowBlank : true,
  128. readOnly:true,
  129. editable:false,
  130. columnWidth : 0.25
  131. },{
  132. xtype:'textfield',
  133. name : "cu_uu",
  134. fieldLabel : "客户UU",
  135. allowBlank : true,
  136. columnWidth : 0.25
  137. },{
  138. format : "Y-m-d",
  139. xtype : "datefield",
  140. name : "updateTime",
  141. fieldLabel : "更新时间",
  142. allowBlank : true,
  143. columnWidth : 0.25
  144. }, {
  145. xtype : "detailGridField",
  146. detnoColumn: 'cc_detno',
  147. storeModel:'saas.model.document.bom',
  148. deleteDetailUrl:basePath+'ducument/bom/deletecontact/',
  149. columns : [
  150. {
  151. text : "ID",
  152. dataIndex : "id",
  153. width : 0,
  154. xtype : "numbercolumn"
  155. },
  156. {
  157. text : "关联ID",
  158. dataIndex : "cc_cuid",
  159. width : 0,
  160. xtype : "numbercolumn"
  161. },
  162. {
  163. text : "联系人",
  164. editor : {
  165. xtype : "textfield"
  166. },
  167. dataIndex : "cc_name",
  168. width : 120.0,
  169. xtype : "",
  170. items : null
  171. },
  172. {
  173. text : "电话",
  174. editor : {
  175. xtype : "textfield"
  176. },
  177. dataIndex : "cc_tel",
  178. width : 120.0,
  179. xtype : "",
  180. items : null
  181. },
  182. {
  183. text : "微信/QQ",
  184. editor : {
  185. xtype : "textfield"
  186. },
  187. dataIndex : "cc_qq",
  188. width : 120.0,
  189. xtype : "",
  190. items : null
  191. },
  192. {
  193. text : "邮箱",
  194. editor : {
  195. xtype : "textfield"
  196. },
  197. dataIndex : "cc_email",
  198. width : 120.0,
  199. xtype : "",
  200. items : null
  201. },
  202. {
  203. editor : {
  204. displayField : "display",
  205. editable : true,
  206. format : "",
  207. hideTrigger : false,
  208. maxLength : 100.0,
  209. minValue : null,
  210. positiveNum : false,
  211. queryMode : "local",
  212. valueField : "value",
  213. xtype : "combo",
  214. store:{
  215. fields: ['display', 'value'],
  216. data : [
  217. {"display":"是", "value":'1'},
  218. {"display":"否", "value":'0'}
  219. ]
  220. }
  221. },
  222. text : "是否默认联系人",
  223. width : 200.0,
  224. dataIndex : "cc_default",
  225. xtype : "",
  226. renderer: function (v, m, r) {
  227. if(v=='0'){
  228. return '';
  229. }else if(v=='1'){
  230. return '是';
  231. }
  232. return v;
  233. }
  234. }]
  235. }],
  236. /**
  237. * 一些初始化viewModel的方法
  238. */
  239. initViewModel: function() {
  240. var me = this,
  241. codeField = me._codeField,
  242. statusField = me._statusField,
  243. statusCodeField = me._statusCodeField,
  244. viewModel = me.getViewModel();
  245. viewModel.set(codeField, '');
  246. viewModel.set('createTime', new Date());
  247. viewModel.set('updateTime', new Date());
  248. if(statusCodeField) {
  249. var o = {};
  250. o['auditBtnText'] = {
  251. bind: '{' + statusCodeField + '}',
  252. get: function(value) {
  253. viewModel.set(statusField, value == 'OPEN' ? '启用' : '禁用');
  254. return value == 'OPEN' ? '禁用' : '启用'
  255. }
  256. };
  257. viewModel.setFormulas(o);
  258. viewModel.set(statusCodeField, "OPEN");
  259. }else {
  260. viewModel.set('auditBtnText', "禁用");
  261. }
  262. }
  263. });