FormPanel.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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.customercontact',
  148. deleteDetailUrl:basePath+'ducument/customer/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. xtype : "detailGridField",
  237. detnoColumn: 'ca_detno',
  238. storeModel:'saas.model.document.customeraddress',
  239. deleteDetailUrl:basePath+'ducument/customer/deleteaddress/',
  240. columns : [
  241. {
  242. text : "ID",
  243. dataIndex : "id",
  244. width : 0,
  245. xtype : "numbercolumn"
  246. },
  247. {
  248. text : "关联ID",
  249. dataIndex : "ca_cuid",
  250. width : 0,
  251. xtype : "numbercolumn"
  252. },
  253. {
  254. text : "送货地址",
  255. editor : {
  256. xtype : "textfield"
  257. },
  258. dataIndex : "ca_address",
  259. width : 120.0,
  260. xtype : "",
  261. items : null
  262. },
  263. {
  264. text : "联系人",
  265. editor : {
  266. xtype : "textfield"
  267. },
  268. dataIndex : "ca_person",
  269. width : 120.0,
  270. xtype : "",
  271. items : null
  272. },
  273. {
  274. text : "联系电话",
  275. editor : {
  276. xtype : "textfield"
  277. },
  278. dataIndex : "ca_phone",
  279. width : 120.0,
  280. xtype : "",
  281. items : null
  282. },
  283. {
  284. editor : {
  285. displayField : "display",
  286. editable : true,
  287. format : "",
  288. hideTrigger : false,
  289. maxLength : 100.0,
  290. minValue : null,
  291. positiveNum : false,
  292. queryMode : "local",
  293. valueField : "value",
  294. xtype : "combo",
  295. store:{
  296. fields: ['display', 'value'],
  297. data : [
  298. {"display":"是", "value":'1'},
  299. {"display":"否", "value":'0'}
  300. ]
  301. },
  302. listeners:{
  303. 'change':function(c,newVal,oldVal){
  304. var grid = c.ownerCt.column.ownerCt.ownerCt;
  305. var nowId = grid.selModel.lastSelected.id;
  306. var items = grid.store.data.items
  307. }
  308. }
  309. },
  310. text : "是否默认地址",
  311. width : 200.0,
  312. dataIndex : "ca_default",
  313. xtype : "",
  314. renderer: function (v, m, r) {
  315. if(v=='0'){
  316. return '';
  317. }else if(v=='1'){
  318. return '是';
  319. }
  320. return v;
  321. }
  322. }]
  323. }],
  324. /**
  325. * 一些初始化viewModel的方法
  326. */
  327. initViewModel: function() {
  328. var me = this,
  329. codeField = me._codeField,
  330. statusField = me._statusField,
  331. statusCodeField = me._statusCodeField,
  332. viewModel = me.getViewModel();
  333. viewModel.set(codeField, '');
  334. viewModel.set('createTime', new Date());
  335. viewModel.set('updateTime', new Date());
  336. if(statusCodeField) {
  337. var o = {};
  338. o['auditBtnText'] = {
  339. bind: '{' + statusCodeField + '}',
  340. get: function(value) {
  341. viewModel.set(statusField, value == 'OPEN' ? '启用' : '禁用');
  342. return value == 'OPEN' ? '禁用' : '启用'
  343. }
  344. };
  345. viewModel.setFormulas(o);
  346. viewModel.set(statusCodeField, "OPEN");
  347. }else {
  348. viewModel.set('auditBtnText', "禁用");
  349. }
  350. }
  351. });