FormPanel.js 12 KB

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