ChildForm.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  1. /**
  2. * Created by zhouy on 2018/10/18.
  3. */
  4. Ext.define('KitchenSink.view.binding.ChildForm', {
  5. extend: 'Ext.window.Window',
  6. xtype: 'document-kind-childwin',
  7. cls:'x-window-dbfind',
  8. layout: 'fit',
  9. modal: true,
  10. width: 500,
  11. //工具类
  12. height: 260,
  13. listeners:{
  14. show:function(w){
  15. if(w.record){
  16. w.down('form').loadRecord(w.record);
  17. }
  18. }
  19. },
  20. initComponent:function(){
  21. var me=this;
  22. Ext.apply(me,{
  23. items:me.setFormItems()
  24. });
  25. me.callParent();
  26. },
  27. etc:{
  28. customerkind:{
  29. items:[{
  30. xtype:'hidden',
  31. name:'id'
  32. },{
  33. xtype:'textfield',
  34. name:'ck_name',
  35. allowBlank:false,
  36. fieldLabel:'客户类型',
  37. maxLength: 20
  38. }]
  39. },
  40. vendorkind:{
  41. items:[{
  42. xtype:'hidden',
  43. name:'id'
  44. },{
  45. xtype:'textfield',
  46. name:'vk_name',
  47. allowBlank:false,
  48. fieldLabel:'供应商类型',
  49. maxLength: 20
  50. }]
  51. },
  52. productkind:{
  53. items:[{
  54. xtype:'hidden',
  55. name:'id'
  56. },{
  57. xtype:'textfield',
  58. name:'pt_name',
  59. allowBlank:false,
  60. fieldLabel:'物料类型',
  61. maxLength: 20
  62. }]
  63. },
  64. personpower:{
  65. items:[{
  66. xtype:'hidden',
  67. name:'id'
  68. },{
  69. xtype:'textfield',
  70. name:'name',
  71. allowBlank:false,
  72. fieldLabel:'角色名称',
  73. maxLength: 20
  74. },{
  75. xtype:'textfield',
  76. name:'description',
  77. allowBlank:false,
  78. fieldLabel:'角色描述',
  79. maxLength: 20
  80. },{
  81. xtype:'textfield',
  82. hidden:true,
  83. name:'code',
  84. allowBlank:true,
  85. fieldLabel:'角色编号',
  86. maxLength: 20
  87. }]
  88. },
  89. bankinformation:{
  90. items:[{
  91. xtype:'hidden',
  92. name:'id'
  93. },{
  94. xtype:'textfield',
  95. name:'bk_bankcode',
  96. allowBlank:false,
  97. fieldLabel:'账户编号',
  98. maxLength: 20
  99. },{
  100. xtype:'textfield',
  101. name:'bk_bankname',
  102. allowBlank:false,
  103. fieldLabel:'账户名称',
  104. maxLength: 20
  105. },{
  106. xtype:'numberfield',
  107. name:'bk_beginamount',
  108. allowBlank:false,
  109. fieldLabel:'期初金额',
  110. hideTrigger: true,
  111. mouseWheelEnabled: false,
  112. minValue: 0,
  113. maxLength:15,
  114. decimalPrecision:2,
  115. enforceMaxLength:true
  116. },
  117. // {
  118. // xtype:'numberfield',
  119. // name:'bk_thisamount',
  120. // allowBlank:true,
  121. // fieldLabel:'当前余额',
  122. // hideTrigger: true,
  123. // mouseWheelEnabled: false,
  124. // beforeLabelTextTpl:'',
  125. // minValue: 0
  126. // }
  127. // ,
  128. {
  129. xtype:'combo',
  130. name:'bk_type',
  131. allowBlank:false,
  132. editable:false,
  133. fieldLabel:'账户类别',
  134. store: [
  135. '现金',
  136. '银行'
  137. ]
  138. },{
  139. xtype:'datefield',
  140. name:'bk_date',
  141. fieldLabel:'建账日期',
  142. format:'Y-m-d H:i:s',
  143. listeners:{
  144. beforerender:function(d){
  145. d.setValue(new Date())
  146. }
  147. }
  148. }, {
  149. xtype:'textfield',
  150. name:'bk_remark',
  151. allowBlank:true,
  152. fieldLabel:'备注',
  153. beforeLabelTextTpl:''
  154. }]
  155. },
  156. productbrand:{
  157. items:[{
  158. xtype:'hidden',
  159. name:'id'
  160. },{
  161. xtype:'textfield',
  162. name:'pb_name',
  163. allowBlank:false,
  164. fieldLabel:'物料品牌',
  165. maxLength: 20
  166. }]
  167. },
  168. productunit:{
  169. items:[{
  170. xtype:'hidden',
  171. name:'id'
  172. },{
  173. xtype:'textfield',
  174. name:'pu_name',
  175. allowBlank:false,
  176. fieldLabel:'计量单位',
  177. maxLength: 20
  178. }]
  179. },
  180. inoutkind:{
  181. items:[{
  182. xtype:'hidden',
  183. name:'id'
  184. },{
  185. xtype:'textfield',
  186. name:'ft_name',
  187. allowBlank:false,
  188. fieldLabel:'收支名称',
  189. maxLength: 20
  190. },{
  191. xtype:'combo',
  192. name:'ft_kind',
  193. allowBlank:false,
  194. fieldLabel:'收支类型',
  195. hideTrigger : false,
  196. maxLength : 100.0,
  197. minValue : null,
  198. positiveNum : false,
  199. queryMode : "local",
  200. valueField : "value",
  201. xtype : "combo",
  202. editable:false,
  203. displayField : "display",
  204. store:{
  205. fields: ['display', 'value'],
  206. data : [
  207. {"display":"收入", "value":'收入'},
  208. {"display":"支出", "value":'支出'}
  209. ]
  210. }
  211. }]
  212. },
  213. address:{
  214. items:[{
  215. xtype:'hidden',
  216. name:'id'
  217. },{
  218. xtype:'textfield',
  219. name:'ad_address',
  220. allowBlank:false,
  221. fieldLabel:'地址详情',
  222. maxLength: 200
  223. }]
  224. },
  225. accountinformation:{
  226. items:[{
  227. xtype:'hidden',
  228. name:'accountId',
  229. hidden:true,
  230. },{
  231. xtype:'textfield',
  232. fieldLabel: '真实姓名',
  233. name: 'realname',
  234. readOnly:true,
  235. editable:false,
  236. allowBlank:true,
  237. maxLength: 30,
  238. beforeLabelTextTpl: "",
  239. },{
  240. xtype:'datamulticombo',
  241. dataUrl:'/api/account/role/list',
  242. fieldLabel: '关联角色',
  243. name: 'roleNames',
  244. allowBlank:true,
  245. maxLength: 20,
  246. beforeLabelTextTpl: "",
  247. },{
  248. xtype:'textfield',
  249. fieldLabel: '手机号码',
  250. name: 'mobile',
  251. readOnly:true,
  252. editable:false,
  253. allowBlank:true,
  254. maxLength: 30,
  255. beforeLabelTextTpl: "",
  256. },{
  257. xtype:'textfield',
  258. fieldLabel: '邮箱',
  259. name: 'email',
  260. readOnly:true,
  261. editable:false,
  262. allowBlank:true,
  263. maxLength: 30,
  264. beforeLabelTextTpl: "",
  265. }]
  266. },
  267. accountadd:{
  268. items:[{
  269. xtype:'textfield',
  270. fieldLabel: '手机号码',
  271. name: 'mobile',
  272. hideTrigger:true,
  273. allowBlank:false,
  274. maxLength: 30,
  275. regex:/^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\d{8}$/,
  276. regexText:'请输入正确的手机号码',
  277. listeners:{
  278. blur:function(f,a,b,c){
  279. var form = f.ownerCt;
  280. form.setLoading(true);
  281. if(f.value&&f.value!=''&&f.isValid()){
  282. Ext.Ajax.request({
  283. url: '/api/account/account/checkMobile?mobile='+f.value,
  284. method: 'GET',
  285. headers:{
  286. 'Access-Control-Allow-Origin': '*',
  287. "Content-Type": 'application/json;charset=UTF-8'
  288. },
  289. success: function (response) {
  290. form.setLoading(false);
  291. var localJson = Ext.decode(response.responseText);
  292. if(localJson.success){
  293. if(!localJson.data.hasRegister){
  294. saas.util.BaseUtil.showSuccessToast('校验成功:手机号未被注册');
  295. }else{
  296. saas.util.BaseUtil.showErrorToast('校验失败:手机号已被注册');
  297. f.setValue('');
  298. }
  299. }else{
  300. saas.util.BaseUtil.showErrorToast('校验失败:'+localJson.message);
  301. }
  302. },
  303. failure: function (response) {
  304. if(response.responseText){
  305. var localJson = Ext.decode(response.responseText);
  306. saas.util.BaseUtil.showErrorToast('校验失败:'+localJson.message);
  307. }else{
  308. saas.util.BaseUtil.showErrorToast('手机号校验接口连接超时');
  309. }
  310. }
  311. });
  312. }
  313. }
  314. }
  315. },{
  316. xtype:'textfield',
  317. fieldLabel: '真实姓名',
  318. name: 'realname',
  319. allowBlank:false,
  320. maxLength: 30,
  321. },{
  322. xtype:'textfield',
  323. fieldLabel: '邮箱',
  324. name: 'email',
  325. allowBlank:false,
  326. regex:/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
  327. regexText:'请输入正确的邮箱',
  328. maxLength: 30,
  329. }]
  330. },
  331. warehouse:{
  332. items:[{
  333. xtype:'hidden',
  334. name:'id'
  335. },{
  336. xtype:'textfield',
  337. fieldLabel: '仓库编号',
  338. name: 'wh_code',
  339. allowBlank:false,
  340. maxLength: 20
  341. },{
  342. xtype:'textfield',
  343. fieldLabel: '仓库名称',
  344. name: 'wh_description',
  345. allowBlank:false,
  346. maxLength: 20
  347. },{
  348. xtype:'combo',
  349. fieldLabel: '仓库类型',
  350. name: 'wh_type',
  351. allowBlank:false,
  352. displayField : "display",
  353. editable:false,
  354. hideTrigger : false,
  355. maxLength : 100.0,
  356. minValue : null,
  357. positiveNum : false,
  358. queryMode : "local",
  359. valueField : "value",
  360. store:{
  361. fields: ['display', 'value'],
  362. data : [
  363. {"display":"良品仓", "value":'良品仓'},
  364. {"display":"不良品仓", "value":'不良品仓'}
  365. ]
  366. }
  367. },{
  368. readOnly:true,
  369. xtype:'textfield',
  370. fieldLabel: '仓库状态',
  371. name: 'wh_status',
  372. value:'已开启',
  373. maxLength: 20
  374. },{
  375. xtype:'hidden',
  376. fieldLabel: '仓库状态码',
  377. name: 'wh_statuscode',
  378. value:'OPEN'
  379. }]
  380. },
  381. employee:{
  382. items:[{
  383. xtype:'hidden',
  384. name:'id'
  385. },{
  386. xtype:'textfield',
  387. fieldLabel: '人员编号',
  388. name: 'em_code',
  389. allowBlank:false,
  390. maxLength: 20
  391. },{
  392. xtype:'textfield',
  393. fieldLabel: '人员名称',
  394. name: 'em_name',
  395. allowBlank:false,
  396. maxLength: 20
  397. },{
  398. xtype:'textfield',
  399. fieldLabel: '联系电话',
  400. name: 'em_mobile',
  401. allowBlank:true,
  402. beforeLabelTextTpl: '',
  403. maxLength: 20
  404. },{
  405. xtype:'textfield',
  406. fieldLabel: '邮箱',
  407. name: 'em_email',
  408. allowBlank:true,
  409. beforeLabelTextTpl: '',
  410. maxLength: 20
  411. },{
  412. value:'正式',
  413. xtype:'combo',
  414. fieldLabel: '人员状态',
  415. name: 'em_class',
  416. allowBlank:false,
  417. displayField : "display",
  418. editable:false,
  419. hideTrigger : false,
  420. maxLength : 100.0,
  421. minValue : null,
  422. positiveNum : false,
  423. queryMode : "local",
  424. valueField : "value",
  425. store:{
  426. fields: ['display', 'value'],
  427. data : [
  428. {"display":"正式", "value":'正式'},
  429. {"display":"离职", "value":'离职'}
  430. ]
  431. }
  432. },]
  433. },
  434. maxnumbers:{
  435. items:[{
  436. xtype:'hidden',
  437. name:'id'
  438. },{
  439. xtype:'textfield',
  440. fieldLabel: '单据名称',
  441. name: 'mn_name',
  442. allowBlank:false,
  443. editable:false,
  444. readOnly:true,
  445. maxLength: 20
  446. },{
  447. xtype:'textfield',
  448. fieldLabel: '单据前缀',
  449. name: 'mn_leadcode',
  450. beforeLabelTextTpl: '',
  451. allowBlank:true,
  452. maxLength: 20
  453. },{
  454. xtype:'combo',
  455. fieldLabel: '单据规则',
  456. name: 'mn_rule',
  457. displayField : "display",
  458. editable:false,
  459. hideTrigger : false,
  460. maxLength : 100.0,
  461. minValue : null,
  462. positiveNum : false,
  463. queryMode : "local",
  464. valueField : "value",
  465. store:{
  466. fields: ['display', 'value'],
  467. data : [
  468. {"display":"年月日", "value":'yyyymmdd'},
  469. {"display":"年月", "value":'yyyymm'},
  470. {"display":"无", "value":'无'}
  471. ]
  472. }
  473. },{
  474. xtype:'numberfield',
  475. hideTrigger : true,
  476. fieldLabel: '流水长度',
  477. name: 'mn_number',
  478. minValue : 0,
  479. allowBlank:false,
  480. mouseWheelEnabled: false
  481. }]
  482. }
  483. },
  484. setFormItems:function() {
  485. var me = this, kind = me.dataKind;
  486. var conf = {
  487. xtype: 'form',
  488. bodyPadding: 10,
  489. border: false,
  490. autoScroll:true,
  491. modelValidation: true,
  492. layout: {
  493. type: 'vbox',
  494. align: 'stretch'
  495. },
  496. defaults: {
  497. labelAlign:'right',
  498. beforeLabelTextTpl: "<font color=\"red\" style=\"position:relative; top:2px;right:2px; font-weight: bolder;\">*</font>",
  499. xtype: 'textfield'
  500. },
  501. buttons: [{
  502. text: '保存',
  503. formBind:true,
  504. handler: me.onSave,
  505. scope:me
  506. }, {
  507. text: '取消',
  508. handler: me.onCancel,
  509. scope:me
  510. }]
  511. };
  512. return Ext.apply(conf, me.etc[kind]);
  513. },
  514. onSave:function(){
  515. var me = this;
  516. var belong = this.belong;
  517. me.setLoading(true);
  518. var form=this.down('form');
  519. var combo = this._combo;
  520. var params = {};
  521. var names = belong.columns.map(column => column.dataIndex);
  522. //账户资料特殊保存逻辑
  523. if(me.dataKind=='accountinformation'){
  524. me.accountinformation();
  525. return;
  526. }
  527. //账户资料新增特殊保存逻辑
  528. if(me.dataKind=='accountadd'){
  529. me.accountadd();
  530. return;
  531. }
  532. Ext.Array.each(names,function(name) {
  533. if(name){
  534. var dataField = form.down('[name='+name+']');
  535. if(dataField&&dataField.value){
  536. params[name] = dataField.value;
  537. params._value = dataField.value;
  538. }
  539. }
  540. });
  541. var idField = form.down('[name='+belong.keyField+']');
  542. params[belong.keyField] = idField.value || 0;
  543. //保存接口
  544. saas.util.BaseUtil.request({
  545. url: belong.reqUrl,
  546. params: JSON.stringify(params),
  547. method: 'POST'
  548. })
  549. .then(function(localJson) {
  550. me.setLoading(false);
  551. if(localJson.success){
  552. var grid = form.ownerCt._parent ? form.ownerCt._parent.lookup('document-kind-Grid') : null;
  553. if(grid){
  554. grid.store.load();
  555. }
  556. if(combo){
  557. combo.store.load(function() {
  558. typeof combo.setValue == 'function' && combo.setValue(params._value);
  559. });
  560. }
  561. saas.util.BaseUtil.showSuccessToast('保存成功');
  562. form.ownerCt.close();
  563. }
  564. })
  565. .catch(function(res) {
  566. me.setLoading(false);
  567. console.error(res);
  568. saas.util.BaseUtil.showErrorToast('保存失败: ' + res.message);
  569. });
  570. },
  571. onCancel:function(){
  572. this.hide();
  573. },
  574. accountinformation:function(){
  575. var me = this;
  576. var belong = this.belong;
  577. me.setLoading(true);
  578. var form=this.down('form');
  579. var combo = this._combo;
  580. var params = {};
  581. var names = belong.columns.map(column => column.dataIndex);
  582. Ext.Array.each(names,function(name) {
  583. if(name){
  584. var dataField = form.down('[name='+name+']');
  585. if(dataField&&dataField.value){
  586. params[name] = dataField.value;
  587. params._value = dataField.value;
  588. }
  589. }
  590. });
  591. //更改参数
  592. var o = '';
  593. Ext.Array.each(params.roleNames,function(item) {
  594. o+=item.value+','
  595. });
  596. o = o.substring(0,o.length-1);
  597. if(o==""){
  598. saas.util.BaseUtil.showErrorToast('关联角色未选择,无法保存!')
  599. }
  600. var _params = {
  601. accountId:Number(params['accountId']),
  602. roleIds:o,
  603. };
  604. //保存接口
  605. saas.util.BaseUtil.request({
  606. url: belong.reqUrl,
  607. params: _params,
  608. method: 'POST',
  609. headers:{
  610. 'Access-Control-Allow-Origin': '*',
  611. "Content-Type":'application/x-www-form-urlencoded'
  612. }
  613. })
  614. .then(function(localJson) {
  615. me.setLoading(false);
  616. if(localJson.success){
  617. saas.util.BaseUtil.showSuccessToast('保存成功');
  618. form.ownerCt._parent.store.load()
  619. form.ownerCt.close();
  620. }
  621. })
  622. .catch(function(res) {
  623. me.setLoading(false);
  624. console.error(res);
  625. saas.util.BaseUtil.showErrorToast('保存失败: ' + res.message);
  626. });
  627. },
  628. accountadd:function(){
  629. var me = this;
  630. var belong = this.belong;
  631. me.setLoading(true);
  632. var form=this.down('form');
  633. var combo = this._combo;
  634. var params = {};
  635. var names = belong.columns.map(column => column.dataIndex);
  636. Ext.Array.each(names,function(name) {
  637. if(name){
  638. var dataField = form.down('[name='+name+']');
  639. if(dataField&&dataField.value){
  640. params[name] = dataField.value;
  641. params._value = dataField.value;
  642. }
  643. }
  644. });
  645. params['username'] = params['mobile'];
  646. params['type'] = 1;
  647. //保存接口
  648. saas.util.BaseUtil.request({
  649. url: belong.reqUrl,
  650. params: JSON.stringify(params),
  651. method: 'POST'
  652. })
  653. .then(function(localJson) {
  654. me.setLoading(false);
  655. if(localJson.success){
  656. form.ownerCt._parent.store.load();
  657. saas.util.BaseUtil.showSuccessToast('保存成功');
  658. form.ownerCt.close();
  659. }
  660. })
  661. .catch(function(res) {
  662. me.setLoading(false);
  663. console.error(res);
  664. saas.util.BaseUtil.showErrorToast('保存失败: ' + res.message);
  665. });
  666. }
  667. });