FormPanel.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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+'document/customer/read/',
  14. _saveUrl:basePath+'document/customer/save',
  15. _openUrl:basePath+'document/customer/open',
  16. _closeUrl:basePath+'document/customer/close',
  17. _deleteUrl:basePath+'document/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+'document/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+'document/customerkind/save',
  64. delUrl:basePath+'document/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. height: 169,
  146. xtype : "detailGridField",
  147. detnoColumn: 'cc_detno',
  148. storeModel:'saas.model.document.customercontact',
  149. deleteDetailUrl:basePath+'document/customer/deletecontact/',
  150. columns : [
  151. {
  152. text : "ID",
  153. dataIndex : "id",
  154. width : 0,
  155. xtype : "numbercolumn"
  156. },
  157. {
  158. text : "关联ID",
  159. dataIndex : "cc_cuid",
  160. width : 0,
  161. xtype : "numbercolumn"
  162. },
  163. {
  164. text : "联系人",
  165. editor : {
  166. xtype : "textfield"
  167. },
  168. dataIndex : "cc_name",
  169. width : 120.0,
  170. xtype : "",
  171. items : null
  172. },
  173. {
  174. text : "电话",
  175. editor : {
  176. xtype : "textfield"
  177. },
  178. dataIndex : "cc_tel",
  179. width : 120.0,
  180. xtype : "",
  181. items : null
  182. },
  183. {
  184. text : "微信/QQ",
  185. editor : {
  186. xtype : "textfield"
  187. },
  188. dataIndex : "cc_qq",
  189. width : 120.0,
  190. xtype : "",
  191. items : null
  192. },
  193. {
  194. text : "邮箱",
  195. editor : {
  196. xtype : "textfield"
  197. },
  198. dataIndex : "cc_email",
  199. width : 120.0,
  200. xtype : "",
  201. items : null
  202. },
  203. {
  204. editor : {
  205. displayField : "display",
  206. editable : true,
  207. format : "",
  208. hideTrigger : false,
  209. maxLength : 100.0,
  210. minValue : null,
  211. positiveNum : false,
  212. queryMode : "local",
  213. valueField : "value",
  214. xtype : "combo",
  215. store:{
  216. fields: ['display', 'value'],
  217. data : [
  218. {"display":"是", "value":'1'},
  219. {"display":"否", "value":'0'}
  220. ]
  221. }
  222. },
  223. text : "是否默认联系人",
  224. width : 200.0,
  225. dataIndex : "cc_default",
  226. xtype : "",
  227. renderer: function (v, m, r) {
  228. if(v=='0'){
  229. return '';
  230. }else if(v=='1'){
  231. return '是';
  232. }
  233. return v;
  234. }
  235. }]
  236. } ,{
  237. height: 169,
  238. xtype : "detailGridField",
  239. detnoColumn: 'ca_detno',
  240. storeModel:'saas.model.document.customeraddress',
  241. deleteDetailUrl:basePath+'document/customer/deleteaddress/',
  242. columns : [
  243. {
  244. text : "ID",
  245. dataIndex : "id",
  246. width : 0,
  247. xtype : "numbercolumn"
  248. },
  249. {
  250. text : "关联ID",
  251. dataIndex : "ca_cuid",
  252. width : 0,
  253. xtype : "numbercolumn"
  254. },
  255. {
  256. text : "送货地址",
  257. editor : {
  258. xtype : "textfield"
  259. },
  260. dataIndex : "ca_address",
  261. width : 120.0,
  262. xtype : "",
  263. items : null
  264. },
  265. {
  266. text : "联系人",
  267. editor : {
  268. xtype : "textfield"
  269. },
  270. dataIndex : "ca_person",
  271. width : 120.0,
  272. xtype : "",
  273. items : null
  274. },
  275. {
  276. text : "联系电话",
  277. editor : {
  278. xtype : "textfield"
  279. },
  280. dataIndex : "ca_phone",
  281. width : 120.0,
  282. xtype : "",
  283. items : null
  284. },
  285. {
  286. editor : {
  287. displayField : "display",
  288. editable : true,
  289. format : "",
  290. hideTrigger : false,
  291. maxLength : 100.0,
  292. minValue : null,
  293. positiveNum : false,
  294. queryMode : "local",
  295. valueField : "value",
  296. xtype : "combo",
  297. store:{
  298. fields: ['display', 'value'],
  299. data : [
  300. {"display":"是", "value":'1'},
  301. {"display":"否", "value":'0'}
  302. ]
  303. },
  304. listeners:{
  305. 'change':function(c,newVal,oldVal){
  306. var grid = c.ownerCt.column.ownerCt.ownerCt;
  307. var nowId = grid.selModel.lastSelected.id;
  308. var items = grid.store.data.items
  309. }
  310. }
  311. },
  312. text : "是否默认地址",
  313. width : 200.0,
  314. dataIndex : "ca_default",
  315. xtype : "",
  316. renderer: function (v, m, r) {
  317. if(v=='0'){
  318. return '';
  319. }else if(v=='1'){
  320. return '是';
  321. }
  322. return v;
  323. }
  324. }]
  325. }],
  326. /**
  327. * 一些初始化viewModel的方法
  328. */
  329. initViewModel: function() {
  330. var me = this,
  331. codeField = me._codeField,
  332. statusField = me._statusField,
  333. statusCodeField = me._statusCodeField,
  334. viewModel = me.getViewModel();
  335. viewModel.set(codeField, '');
  336. viewModel.set('createTime', new Date());
  337. viewModel.set('updateTime', new Date());
  338. if(statusCodeField) {
  339. var o = {};
  340. o['auditBtnText'] = {
  341. bind: '{' + statusCodeField + '}',
  342. get: function(value) {
  343. viewModel.set(statusField, value == 'OPEN' ? '已开启' : '已关闭');
  344. return value == 'OPEN' ? '已关闭' : '已开启'
  345. }
  346. };
  347. viewModel.setFormulas(o);
  348. viewModel.set(statusCodeField, "OPEN");
  349. }else {
  350. viewModel.set('auditBtnText', "已关闭");
  351. }
  352. }
  353. });