Kind.js 13 KB

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