FormPanel.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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:'/api/document/customer/read/',
  14. _saveUrl:'/api/document/customer/save',
  15. _openUrl:'/api/document/customer/open',
  16. _closeUrl:'/api/document/customer/close',
  17. _deleteUrl:'/api/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. editable:false,
  51. xtype : "remotecombo",
  52. storeUrl:'/api/document/customerkind/getCombo',
  53. name : "cu_type",
  54. fieldLabel : "客户类型",
  55. allowBlank : false,
  56. columnWidth : 0.25,
  57. hiddenBtn:false,//true 则会关闭新增按钮功能
  58. addHandler:function(b){
  59. var document = Ext.create('saas.view.document.kind.Kind',{});
  60. var form = this.ownerCmp.ownerCt;
  61. this.dialog = form.getController().getView().add({
  62. xtype: 'document-kind-childwin',
  63. bind: {
  64. title: '新增客户类型'
  65. },
  66. dataKind:'customerkind',
  67. belong:document.etc['customerkind'],
  68. _parent:form,
  69. _combo:this.ownerCmp,
  70. record:null,
  71. session: true
  72. });
  73. this.dialog.show();
  74. }
  75. },{
  76. format : "Y-m-d",
  77. xtype : "datefield",
  78. name : "createTime",
  79. fieldLabel : "创建时间",
  80. allowBlank : true,
  81. columnWidth : 0.25
  82. },{
  83. format : "Y-m-d",
  84. xtype : "datefield",
  85. name : "cu_begindate",
  86. fieldLabel : "期初日期",
  87. allowBlank : true,
  88. columnWidth : 0.25
  89. },{
  90. xtype : "numberfield",
  91. hideTrigger:true,
  92. name : "cu_beginaramount",
  93. fieldLabel : "期初应收",
  94. allowBlank : true,
  95. columnWidth : 0.25
  96. },{
  97. xtype : "numberfield",
  98. hideTrigger:true,
  99. name : "cu_beginprerecamount",
  100. fieldLabel : "期初预收",
  101. allowBlank : true,
  102. columnWidth : 0.25
  103. },{
  104. xtype : "numberfield",
  105. hideTrigger:true,
  106. name : "cu_promisedays",
  107. fieldLabel : "承付天数",
  108. allowBlank : true,
  109. columnWidth : 0.25
  110. },{
  111. xtype : "numberfield",
  112. name : "cu_taxrate",
  113. fieldLabel : "税率",
  114. allowBlank : true,
  115. columnWidth : 0.25
  116. },{
  117. xtype : "numberfield",
  118. name : "cu_ta",
  119. fieldLabel : "应收款余额",
  120. allowBlank : true,
  121. readOnly:true,
  122. editable:false,
  123. columnWidth : 0.25
  124. },{
  125. xtype:'textfield',
  126. name : "cu_uu",
  127. fieldLabel : "客户UU",
  128. allowBlank : true,
  129. columnWidth : 0.25
  130. },{
  131. format : "Y-m-d",
  132. xtype : "datefield",
  133. name : "updateTime",
  134. fieldLabel : "更新时间",
  135. allowBlank : true,
  136. columnWidth : 0.25
  137. }, {
  138. height: 169,
  139. xtype : "detailGridField",
  140. detnoColumn: 'cc_detno',
  141. storeModel:'saas.model.document.customercontact',
  142. deleteDetailUrl:'/api/document/customer/deletecontact/',
  143. columns : [
  144. {
  145. text : "ID",
  146. dataIndex : "id",
  147. width : 0,
  148. xtype : "numbercolumn"
  149. },
  150. {
  151. text : "关联ID",
  152. dataIndex : "cc_cuid",
  153. width : 0,
  154. xtype : "numbercolumn"
  155. },
  156. {
  157. text : "联系人",
  158. editor : {
  159. xtype : "textfield"
  160. },
  161. dataIndex : "cc_name",
  162. width : 120.0,
  163. xtype : "",
  164. items : null
  165. },
  166. {
  167. text : "电话",
  168. editor : {
  169. xtype : "textfield"
  170. },
  171. dataIndex : "cc_tel",
  172. width : 120.0,
  173. xtype : "",
  174. items : null
  175. },
  176. {
  177. text : "微信/QQ",
  178. editor : {
  179. xtype : "textfield"
  180. },
  181. dataIndex : "cc_qq",
  182. width : 120.0,
  183. xtype : "",
  184. items : null
  185. },
  186. {
  187. text : "邮箱",
  188. editor : {
  189. xtype : "textfield"
  190. },
  191. dataIndex : "cc_email",
  192. width : 120.0,
  193. xtype : "",
  194. items : null
  195. },
  196. {
  197. editor : {
  198. displayField : "display",
  199. editable:false,
  200. format : "",
  201. hideTrigger : false,
  202. maxLength : 100.0,
  203. minValue : null,
  204. positiveNum : false,
  205. queryMode : "local",
  206. valueField : "value",
  207. xtype : "combo",
  208. store:{
  209. fields: ['display', 'value'],
  210. data : [
  211. {"display":"是", "value":'1'},
  212. {"display":"否", "value":'0'}
  213. ]
  214. }
  215. },
  216. text : "是否默认联系人",
  217. width : 200.0,
  218. dataIndex : "cc_default",
  219. xtype : "",
  220. renderer: function (v, m, r) {
  221. if(v=='0'){
  222. return '';
  223. }else if(v=='1'){
  224. return '是';
  225. }
  226. return v;
  227. }
  228. }]
  229. } ,{
  230. height: 169,
  231. xtype : "detailGridField",
  232. detnoColumn: 'ca_detno',
  233. storeModel:'saas.model.document.customeraddress',
  234. deleteDetailUrl:'/api/document/customer/deleteaddress/',
  235. columns : [
  236. {
  237. text : "ID",
  238. dataIndex : "id",
  239. width : 0,
  240. xtype : "numbercolumn"
  241. },
  242. {
  243. text : "关联ID",
  244. dataIndex : "ca_cuid",
  245. width : 0,
  246. xtype : "numbercolumn"
  247. },
  248. {
  249. text : "送货地址",
  250. editor : {
  251. xtype : "textfield"
  252. },
  253. dataIndex : "ca_address",
  254. width : 120.0,
  255. xtype : "",
  256. items : null
  257. },
  258. {
  259. text : "联系人",
  260. editor : {
  261. xtype : "textfield"
  262. },
  263. dataIndex : "ca_person",
  264. width : 120.0,
  265. xtype : "",
  266. items : null
  267. },
  268. {
  269. text : "联系电话",
  270. editor : {
  271. xtype : "textfield"
  272. },
  273. dataIndex : "ca_phone",
  274. width : 120.0,
  275. xtype : "",
  276. items : null
  277. },
  278. {
  279. editor : {
  280. editable:false,
  281. displayField : "display",
  282. format : "",
  283. hideTrigger : false,
  284. maxLength : 100.0,
  285. minValue : null,
  286. positiveNum : false,
  287. queryMode : "local",
  288. valueField : "value",
  289. xtype : "combo",
  290. store:{
  291. fields: ['display', 'value'],
  292. data : [
  293. {"display":"是", "value":'1'},
  294. {"display":"否", "value":'0'}
  295. ]
  296. },
  297. listeners:{
  298. 'change':function(c,newVal,oldVal){
  299. var grid = c.ownerCt.column.ownerCt.ownerCt;
  300. var nowId = grid.selModel.lastSelected.id;
  301. var items = grid.store.data.items
  302. }
  303. }
  304. },
  305. text : "是否默认地址",
  306. width : 200.0,
  307. dataIndex : "ca_default",
  308. xtype : "",
  309. renderer: function (v, m, r) {
  310. if(v=='0'){
  311. return '';
  312. }else if(v=='1'){
  313. return '是';
  314. }
  315. return v;
  316. }
  317. }]
  318. }],
  319. /**
  320. * 一些初始化viewModel的方法
  321. */
  322. initViewModel: function() {
  323. var me = this,
  324. codeField = me._codeField,
  325. statusField = me._statusField,
  326. statusCodeField = me._statusCodeField,
  327. viewModel = me.getViewModel();
  328. viewModel.set(codeField, '');
  329. viewModel.set('createTime', new Date());
  330. viewModel.set('updateTime', new Date());
  331. if(statusCodeField) {
  332. var o = {};
  333. o['auditBtnText'] = {
  334. bind: '{' + statusCodeField + '}',
  335. get: function(value) {
  336. viewModel.set(statusField, value == 'OPEN' ? '已开启' : '已关闭');
  337. return value == 'OPEN' ? '禁用' : '启用'
  338. }
  339. };
  340. viewModel.setFormulas(o);
  341. viewModel.set(statusCodeField, "OPEN");
  342. }else {
  343. viewModel.set('auditBtnText', "禁用");
  344. }
  345. }
  346. });