FormPanel.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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. codeInHeader: false,
  20. defaultItems: [{
  21. xtype: 'hidden',
  22. name: 'id',
  23. fieldLabel: 'id',
  24. allowBlank: true,
  25. columnWidth: 0.25
  26. },{
  27. xtype: 'textfield',
  28. name: 'cu_code',
  29. fieldLabel: '客户编号',
  30. allowBlank: false,
  31. columnWidth: 0.25
  32. },{
  33. xtype: 'textfield',
  34. name: 'cu_name',
  35. fieldLabel: '客户名称',
  36. allowBlank: false,
  37. columnWidth: 0.25
  38. },{
  39. xtype: 'textfield',
  40. name: 'cu_shortname',
  41. fieldLabel: '客户简称',
  42. columnWidth: 0.25
  43. },{
  44. editable:false,
  45. xtype : "remotecombo",
  46. storeUrl:'/api/document/customerkind/getCombo',
  47. name : "cu_type",
  48. fieldLabel : "客户类型",
  49. columnWidth : 0.25,
  50. hiddenBtn:false,//true 则会关闭新增按钮功能
  51. addHandler:function(b){
  52. var document = Ext.create('saas.view.document.kind.Kind',{});
  53. var form = this.ownerCmp.ownerCt;
  54. this.dialog = form.getController().getView().add({
  55. xtype: 'document-kind-childwin',
  56. bind: {
  57. title: '新增客户类型'
  58. },
  59. dataKind:'customerkind',
  60. belong:document.etc['customerkind'],
  61. _parent:form,
  62. _combo:this.ownerCmp,
  63. record:null,
  64. session: true
  65. });
  66. this.dialog.show();
  67. }
  68. },{
  69. xtype: 'hidden',
  70. name: 'cu_status',
  71. fieldLabel: '状态',
  72. allowBlank: true,
  73. columnWidth: 0
  74. },{
  75. xtype: 'hidden',
  76. name: 'cu_statuscode',
  77. fieldLabel: '状态码',
  78. allowBlank: true,
  79. columnWidth: 0.25
  80. },{
  81. xtype : "datefield",
  82. name : "cu_begindate",
  83. format:'Y-m-d',
  84. fieldLabel : "期初日期",
  85. allowBlank : true,
  86. columnWidth : 0.25
  87. },{
  88. xtype : "numberfield",
  89. hideTrigger:true,
  90. name : "cu_beginaramount",
  91. fieldLabel : "期初应收",
  92. allowBlank : true,
  93. columnWidth : 0.25,
  94. decimalPrecision: 2,
  95. minValue:0,
  96. renderer : function(v) {
  97. var arr = (v + '.').split('.');
  98. var xr = (new Array(arr[1].length)).fill('0');
  99. var format = '0.' + xr.join('');
  100. return Ext.util.Format.number(v, format);
  101. },
  102. },{
  103. xtype : "numberfield",
  104. hideTrigger:true,
  105. name : "cu_beginprerecamount",
  106. fieldLabel : "期初预收",
  107. allowBlank : true,
  108. columnWidth : 0.25,
  109. decimalPrecision: 2,
  110. minValue:0,
  111. renderer : function(v) {
  112. var arr = (v + '.').split('.');
  113. var xr = (new Array(arr[1].length)).fill('0');
  114. var format = '0.' + xr.join('');
  115. return Ext.util.Format.number(v, format);
  116. },
  117. },{
  118. xtype : "numberfield",
  119. name : "cu_taxrate",
  120. fieldLabel : "税率",
  121. allowBlank : false,
  122. columnWidth : 0.25,
  123. minValue:0,
  124. maxValue:100,
  125. },{
  126. xtype : "numberfield",
  127. hideTrigger:true,
  128. name : "cu_promisedays",
  129. fieldLabel : "结算天数",
  130. allowBlank : true,
  131. columnWidth : 0.25,
  132. decimalPrecision:0,
  133. minValue:0
  134. },{
  135. xtype : "numberfield",
  136. hideTrigger:true,
  137. name : "cu_credit",
  138. fieldLabel : "额度",
  139. allowBlank : true,
  140. columnWidth : 0.25,
  141. decimalPrecision: 8,
  142. minValue:0,
  143. renderer : function(v) {
  144. var arr = (v + '.').split('.');
  145. var xr = (new Array(arr[1].length)).fill('0');
  146. var format = '0.' + xr.join('');
  147. return Ext.util.Format.number(v, format);
  148. },
  149. }, {
  150. xtype : "hidden",
  151. name : "cu_sellerid",
  152. fieldLabel : "业务员id",
  153. defaultValue:saas.util.BaseUtil.getCurrentUser().id
  154. }, {
  155. xtype : "hidden",
  156. name : "cu_sellercode",
  157. fieldLabel : "业务员code",
  158. }, {
  159. xtype : "employeeDbfindTrigger",
  160. name : "cu_sellername",
  161. fieldLabel : "业务员",
  162. columnWidth : 0.25,
  163. defaultValue:saas.util.BaseUtil.getCurrentUser().realname
  164. },{
  165. xtype : "hidden",
  166. name : "cu_nsrzh",
  167. fieldLabel : "纳税人识别号",
  168. allowBlank : true,
  169. columnWidth : 0.25
  170. },{
  171. xtype : "hidden",
  172. name : "cu_bankaccount",
  173. fieldLabel : "开户银行",
  174. allowBlank : true,
  175. columnWidth : 0.25
  176. },{
  177. xtype : "hidden",
  178. name : "cu_bankcode",
  179. fieldLabel : "银行账户",
  180. allowBlank : true,
  181. columnWidth : 0.25
  182. },{
  183. xtype:'hidden',
  184. name : "cu_uu",
  185. fieldLabel : "客户UU",
  186. allowBlank : true,
  187. readOnly:true,
  188. editable:false,
  189. columnWidth : 0.25
  190. },{
  191. xtype:'textfield',
  192. name : "cu_leftamount",
  193. fieldLabel : "应收款余额",
  194. allowBlank : true,
  195. readOnly:true,
  196. columnWidth : 0.25,
  197. decimalPrecision: 8,
  198. renderer : function(v) {
  199. var arr = (v + '.').split('.');
  200. var xr = (new Array(arr[1].length)).fill('0');
  201. var format = '0.' + xr.join('');
  202. return Ext.util.Format.number(v, format);
  203. },
  204. },{
  205. xtype : "datefield",
  206. name : "createTime",
  207. fieldLabel : "创建时间",
  208. allowBlank : true,
  209. hidden:true,
  210. columnWidth : 0
  211. },{
  212. xtype : "datefield",
  213. name : "updateTime",
  214. fieldLabel : "更新时间",
  215. allowBlank : true,
  216. hidden:true,
  217. columnWidth : 0
  218. },{
  219. fieldLabel : "备注",
  220. xtype:'textfield',
  221. name : "cu_remark",
  222. columnWidth : 0.75
  223. }, {
  224. xtype : "detailGridField",
  225. storeModel:'saas.model.document.customercontact',
  226. detnoColumn: 'cc_detno',
  227. showCount: false,
  228. deleteDetailUrl:'/api/document/customer/deletecontact',
  229. height:145,
  230. emptyRows: 3,
  231. columns : [
  232. {
  233. text : "ID",
  234. dataIndex : "id",
  235. hidden : true,
  236. xtype : "numbercolumn"
  237. },
  238. {
  239. text : "关联ID",
  240. dataIndex : "cc_cuid",
  241. hidden : true,
  242. xtype : "numbercolumn"
  243. },
  244. {
  245. allowBlank:false,
  246. text : "联系人",
  247. editor : {
  248. xtype : "textfield"
  249. },
  250. dataIndex : "cc_name",
  251. width:110
  252. },
  253. {
  254. allowBlank:false,
  255. text : "电话",
  256. editor : {
  257. regex:/^1(3|4|5|7|8|9)\d{9}$/,
  258. regexText:'请输入正确的手机号码',
  259. hideTrigger:true,
  260. xtype : "textfield"
  261. },
  262. dataIndex : "cc_tel",
  263. width:110
  264. },
  265. {
  266. allowBlank:true,
  267. text : "微信/QQ",
  268. editor : {
  269. xtype : "textfield"
  270. },
  271. dataIndex : "cc_qq",
  272. width:110
  273. },
  274. {
  275. text : "邮箱",
  276. editor : {
  277. xtype : "textfield"
  278. },
  279. dataIndex : "cc_email",
  280. width:180
  281. },
  282. {
  283. editor : {
  284. displayField : "display",
  285. format : "",
  286. hideTrigger : false,
  287. maxLength : 100.0,
  288. minValue : null,
  289. positiveNum : false,
  290. queryMode : "local",
  291. valueField : "value",
  292. xtype : "combo",
  293. store:{
  294. fields: ['display', 'value'],
  295. data : [
  296. {"display":"是", "value":'1'},
  297. {"display":"否", "value":'0'}
  298. ]
  299. },
  300. listeners:{
  301. 'change':function(c,newVal,oldVal){
  302. if(newVal=='1'){
  303. var grid = c.ownerCt.column.ownerCt.ownerCt;
  304. var nowId = grid.selModel.lastSelected.id;
  305. var items = grid.store.data.items
  306. for (let index = 0; index < items.length; index++) {
  307. if(items[index].id!=nowId){
  308. items[index].set('cc_default',"")
  309. }
  310. }
  311. }
  312. }
  313. }
  314. },
  315. text : "默认联系人",
  316. width:110 ,
  317. dataIndex : "cc_default",
  318. xtype : "",
  319. renderer: function (v, m, r) {
  320. if(v=='0'){
  321. return '';
  322. }else if(v=='1'){
  323. return '是';
  324. }
  325. return v;
  326. }
  327. }]
  328. } ,{
  329. xtype : "detailGridField",
  330. storeModel:'saas.model.document.customeraddress',
  331. detnoColumn: 'ca_detno',
  332. showCount: false,
  333. deleteDetailUrl:'/api/document/customer/deleteaddress',
  334. height:145,
  335. emptyRows: 3,
  336. columns : [
  337. {
  338. text : "ID",
  339. dataIndex : "id",
  340. hidden : true,
  341. xtype : "numbercolumn"
  342. },
  343. {
  344. text : "关联ID",
  345. dataIndex : "ca_cuid",
  346. hidden : true,
  347. xtype : "numbercolumn"
  348. },
  349. {
  350. allowBlank:false,
  351. text : "送货地址",
  352. editor : {
  353. xtype : "textfield"
  354. },
  355. dataIndex : "ca_address",
  356. width:300
  357. },
  358. {
  359. allowBlank:true,
  360. text : "联系人",
  361. editor : {
  362. xtype : "textfield"
  363. },
  364. dataIndex : "ca_person",
  365. width:110
  366. },
  367. {
  368. allowBlank:true,
  369. text : "联系电话",
  370. editor : {
  371. regex:/^1(3|4|5|7|8|9)\d{9}$/,
  372. regexText:'请输入正确的手机号码',
  373. xtype : "textfield",
  374. hideTrigger:true,
  375. },
  376. dataIndex : "ca_phone",
  377. width:110
  378. },
  379. {
  380. editor : {
  381. displayField : "display",
  382. format : "",
  383. hideTrigger : false,
  384. maxLength : 100.0,
  385. minValue : null,
  386. positiveNum : false,
  387. queryMode : "local",
  388. valueField : "value",
  389. xtype : "combo",
  390. store:{
  391. fields: ['display', 'value'],
  392. data : [
  393. {"display":"是", "value":'1'},
  394. {"display":"否", "value":'0'}
  395. ]
  396. },
  397. listeners:{
  398. 'change':function(c,newVal,oldVal){
  399. if(newVal=='1'){
  400. var grid = c.ownerCt.column.ownerCt.ownerCt;
  401. var nowId = grid.selModel.lastSelected.id;
  402. var items = grid.store.data.items
  403. for (let index = 0; index < items.length; index++) {
  404. if(items[index].id!=nowId){
  405. items[index].set('ca_default',"")
  406. }
  407. }
  408. }
  409. }
  410. }
  411. },
  412. text : "默认地址",
  413. dataIndex : "ca_default",
  414. width:110,
  415. renderer: function (v, m, r) {
  416. if(v=='0'){
  417. return '';
  418. }else if(v=='1'){
  419. return '是';
  420. }
  421. return v;
  422. }
  423. }]
  424. }],
  425. defaultButtons:[{
  426. cls: 'x-formpanel-btn-blue',
  427. xtype: 'button',
  428. text: '新增',
  429. bind: {
  430. hidden: '{!id}'
  431. },
  432. handler: 'add'
  433. }, {
  434. xtype: 'button',
  435. text: '保存',
  436. handler: 'onSave',
  437. }, {
  438. xtype: 'button',
  439. text: '删除',
  440. handler: 'delete'
  441. }, {
  442. xtype: 'button',
  443. bind: {
  444. text: '{auditBtnText}'
  445. },
  446. handler: "auditBtnClick",
  447. }],
  448. auditTexts: {
  449. auditCode: 'BANNED',
  450. auditText: '已禁用',
  451. unAuditCode: 'ENABLE',
  452. unAuditText: '已启用',
  453. auditBtnText: '禁用',
  454. unAuditBtnText: '启用',
  455. }
  456. });