Kind.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. /**
  2. * Created by zhouy on 2018/10/18.
  3. */
  4. Ext.define('saas.view.document.kind.Kind', {
  5. extend: 'Ext.panel.Panel',
  6. xtype: 'document-kind',
  7. autoScroll: true,
  8. layout:'fit',
  9. controller:'document-kind',
  10. viewModel: {
  11. type: 'document-kind'
  12. },
  13. defaultType:'',
  14. requires: [
  15. 'Ext.button.Segmented'
  16. ],
  17. tbar: [{
  18. xtype: 'segmentedbutton',
  19. reference: 'dataKind',
  20. value: 'customerkind',
  21. name : 'segmentedbutton',
  22. bind:'{segmented}',
  23. items: [{
  24. name:'customerkind',
  25. text: '客户',
  26. value: 'customerkind',
  27. typeText:'客户类型'
  28. }, {
  29. name:'vendorkind',
  30. text: '供应商',
  31. value: 'vendorkind',
  32. typeText:'供应商类型'
  33. }, {
  34. name:'productkind',
  35. text: '物料',
  36. value: 'productkind',
  37. typeText:'物料类型'
  38. }, {
  39. name:'inoutkind',
  40. text: '收支',
  41. value: 'inoutkind',
  42. typeText:'收支类别'
  43. }],
  44. listeners: {
  45. toggle: 'onKindToggle'
  46. }
  47. },'->',
  48. {
  49. xtype:'button',
  50. text:'新增',
  51. listeners: {
  52. click: 'onAdd'
  53. }
  54. },{
  55. xtype:'button',
  56. text:'刷新',
  57. listeners: {
  58. click: 'onRefresh'
  59. }
  60. }],
  61. items:[{
  62. xtype:'grid',
  63. reference: 'document-kind-Grid',
  64. margin: '10 0 0 0',
  65. flex: 1,
  66. frame:true,
  67. bind:{
  68. selection: '{selectedCompany}'
  69. },
  70. listeners:{
  71. render:'loadDefualt'
  72. }
  73. }],
  74. etc:{
  75. customerkind:{
  76. columns: [{
  77. text: '客户类型',
  78. dataIndex: 'ck_name',
  79. flex: 1
  80. }],
  81. keyField:'id',
  82. reqUrl:'/api/document/customerkind/save',
  83. delUrl:'/api/document/customerkind/delete'
  84. },
  85. vendorkind:{
  86. columns: [{
  87. text: '供应商类型',
  88. dataIndex: 'vk_name',
  89. flex: 1
  90. }],
  91. keyField:'id',
  92. reqUrl:'/api/document/vendorkind/save',
  93. delUrl:'/api/document/vendorkind/delete'
  94. },
  95. productkind:{
  96. columns: [{
  97. text: '物料类型',
  98. dataIndex: 'pt_name',
  99. flex: 1
  100. }],
  101. keyField:'id',
  102. reqUrl:'/api/document/producttype/save',
  103. delUrl:'/api/document/producttype/delete'
  104. },
  105. productbrand:{
  106. columns: [{
  107. text: '物料品牌',
  108. dataIndex: 'pb_name',
  109. flex: 1
  110. }],
  111. keyField:'id',
  112. reqUrl:'/api/document/productbrand/save',
  113. delUrl:'/api/document/productbrand/delete'
  114. },
  115. productunit:{
  116. columns: [{
  117. text: '计量单位',
  118. dataIndex: 'pu_name',
  119. flex: 1
  120. }],
  121. keyField:'id',
  122. reqUrl:'/api/document/productunit/save',
  123. delUrl:'/api/document/productunit/delete'
  124. },
  125. bankinformation:{
  126. columns: [{
  127. text: '账户编号',
  128. dataIndex: 'bk_bankcode',
  129. flex: 1
  130. },{
  131. text: '账户名称',
  132. dataIndex: 'bk_bankname',
  133. flex: 1
  134. },{
  135. text: '账户类别',
  136. dataIndex: 'bk_type',
  137. flex: 1,
  138. },{
  139. text: '期初金额',
  140. dataIndex: 'bk_beginamount',
  141. xtype: 'numbercolumn',
  142. renderer : function(v) {
  143. var arr = (v + '.').split('.');
  144. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  145. var format = '0,000.' + xr.join();
  146. return Ext.util.Format.number(v, format);
  147. },
  148. flex: 1
  149. },{
  150. text: '当前余额',
  151. dataIndex: 'bk_thisamount',
  152. xtype: 'numbercolumn',
  153. renderer : function(v) {
  154. var arr = (v + '.').split('.');
  155. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  156. var format = '0,000.' + xr.join();
  157. return Ext.util.Format.number(v, format);
  158. },
  159. flex: 1
  160. },{
  161. xtype:'datecolumn',
  162. text: '建账日期',
  163. format:'Y-m-d',
  164. dataIndex: 'bk_date',
  165. flex: 1
  166. }, {
  167. text: '备注',
  168. dataIndex: 'bk_remark',
  169. flex: 1
  170. }],
  171. keyField:'id',
  172. reqUrl: '/api/document/bankinformation/save',
  173. delUrl: '/api/document/bankinformation/delete'
  174. },
  175. inoutkind:{
  176. columns: [{
  177. text: '收支名称',
  178. dataIndex: 'ft_name',
  179. flex: 1
  180. },{
  181. text: '收支类别',
  182. dataIndex: 'ft_kind',
  183. flex: 1
  184. }],
  185. keyField:'id',
  186. reqUrl: '/api/document/fundinouttype/save',
  187. delUrl: '/api/document/fundinouttype/delete'
  188. },
  189. address:{
  190. columns: [{
  191. text: '地址名称',
  192. dataIndex: 'ad_address',
  193. flex: 1
  194. }],
  195. keyField:'id',
  196. reqUrl: '/api/document/address/save',
  197. delUrl: '/api/document/address/delete'
  198. },
  199. maxnumbers:{
  200. columns: [{
  201. text : "单据名称",
  202. width : 200.0,
  203. dataIndex : "mn_caller"
  204. },
  205. {
  206. text : "单据前缀",
  207. dataIndex : "mn_leadcode",
  208. width : 150.0
  209. },
  210. {
  211. text : "单据规则",
  212. dataIndex : "mn_rule",
  213. width : 250.0
  214. },{
  215. text : "流水长度",
  216. dataIndex : "mn_number",
  217. width : 90.0,
  218. xtype: 'numbercolumn',
  219. }],
  220. keyField:'id',
  221. reqUrl:'/api/commons/number/save'
  222. },
  223. personpower:{
  224. columns: [ {
  225. text : "编号",
  226. dataIndex : "code",
  227. width : 150.0,
  228. xtype : "",
  229. },{
  230. text : "角色名称",
  231. width : 200.0,
  232. dataIndex : "name",
  233. xtype : "",
  234. },
  235. {
  236. text : "角色描述",
  237. dataIndex : "description",
  238. width : 250.0
  239. }
  240. ],
  241. keyField:'id',
  242. reqUrl:'/api/account/role/save',
  243. updateUrl:'/api/account/role/update',
  244. },
  245. accountinformation:{
  246. columns:[{
  247. dataIndex:'accountId',
  248. },{
  249. dataIndex: 'roleNames',
  250. width: 150
  251. },{
  252. dataIndex: 'mobile',
  253. width: 110
  254. },{
  255. dataIndex: 'email',
  256. width: 110
  257. }],
  258. reqUrl:'/api/account/account/bind/roles',
  259. },
  260. accountadd:{
  261. columns:[{
  262. dataIndex:'realname',
  263. },{
  264. dataIndex: 'mobile',
  265. },{
  266. dataIndex: 'email',
  267. }],
  268. reqUrl: '/api/account/account/register/add',
  269. },
  270. employee:{
  271. columns: [{
  272. text: '人员编号',
  273. dataIndex: 'em_code',
  274. width: 150
  275. },{
  276. text: '人员名称',
  277. dataIndex: 'em_name',
  278. width: 110
  279. },{
  280. text: '联系电话',
  281. dataIndex: 'em_mobile',
  282. width: 110
  283. },{
  284. text: '邮箱',
  285. dataIndex: 'em_email',
  286. width: 180
  287. },{
  288. text: '人员状态',
  289. dataIndex: 'em_class',
  290. width:90,
  291. xtype: 'actioncolumn',
  292. align : 'center',
  293. items: [{
  294. iconCls:'',
  295. getClass: function(v, meta, rec) {
  296. if(rec.get('em_class')=='正式'){
  297. return 'x-grid-checkcolumn-checked-btn';
  298. }else{
  299. return 'x-grid-checkcolumn-btn';
  300. }
  301. },
  302. handler: function(view, rowIndex, colIndex) {
  303. var rec = view.getStore().getAt(rowIndex);
  304. var type=rec.get('em_class')=='正式'?true:false;
  305. // 禁用/启用
  306. var form = this.ownerCt.ownerCt.ownerCt;
  307. var grid = this.ownerCt.ownerCt;
  308. saas.util.BaseUtil.request({
  309. url: (!type?form._openUrl:form._closeUrl)+'/'+rec.get('id'),
  310. params: '',
  311. method: 'POST',
  312. })
  313. .then(function(localJson) {
  314. if(localJson.success){
  315. saas.util.BaseUtil.showSuccessToast('操作成功');
  316. grid.store.load();
  317. }
  318. })
  319. .catch(function(res) {
  320. console.error(res);
  321. saas.util.BaseUtil.showErrorToast('操作失败: ' + res.message);
  322. });
  323. }
  324. }]
  325. }],
  326. keyField:'id',
  327. reqUrl: '/api/document/employee/save',
  328. delUrl: '/api/document/employee/delete'
  329. },
  330. warehouse:{
  331. columns: [{
  332. text: '编号',
  333. dataIndex: 'wh_code',
  334. width: 150
  335. },{
  336. text: '仓库名称',
  337. dataIndex: 'wh_description',
  338. width: 200
  339. },{
  340. text: '类型',
  341. dataIndex: 'wh_type',
  342. width: 110
  343. },{
  344. text: '仓库状态码',
  345. dataIndex: 'wh_status',
  346. hidden:true,
  347. },{
  348. text: '仓库状态',
  349. dataIndex: 'wh_statuscode',
  350. width:90,
  351. xtype: 'actioncolumn',
  352. align : 'center',
  353. items: [{
  354. iconCls:'',
  355. getClass: function(v, meta, rec) {
  356. if(rec.get('wh_statuscode')=='ENABLE'){
  357. return 'x-grid-checkcolumn-checked-btn';
  358. }else{
  359. return 'x-grid-checkcolumn-btn';
  360. }
  361. },
  362. handler: function(view, rowIndex, colIndex) {
  363. var rec = view.getStore().getAt(rowIndex);
  364. var type=rec.get('wh_statuscode')=='ENABLE'?true:false;
  365. // 禁用/启用
  366. var form = this.ownerCt.ownerCt.ownerCt;
  367. var grid = this.ownerCt.ownerCt;
  368. saas.util.BaseUtil.request({
  369. url: (!type?form._openUrl:form._closeUrl)+'/'+rec.get('id'),
  370. params: '',
  371. method: 'POST',
  372. })
  373. .then(function(localJson) {
  374. if(localJson.success){
  375. saas.util.BaseUtil.showSuccessToast('操作成功');
  376. grid.store.load();
  377. }
  378. })
  379. .catch(function(res) {
  380. console.error(res);
  381. saas.util.BaseUtil.showErrorToast('操作失败: ' + res.message);
  382. });
  383. }
  384. }]
  385. }],
  386. keyField:'id',
  387. reqUrl: '/api/document/warehouse/save',
  388. delUrl: '/api/document/warehouse/delete'
  389. }
  390. },
  391. refresh:function(){
  392. var me = this;
  393. var grid = me.items.items[0];
  394. var button = grid.ownerCt.dockedItems.items[0].down('[name='+grid.ownerCt.ownerCt.viewConfig+']');
  395. if(button&&button.xtype!="tbfill"){
  396. button.click();
  397. me.ownerCt.setTitle(button.typeText + '查询');
  398. }
  399. }
  400. })