Kind.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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. xtype : "",
  205. },
  206. {
  207. text : "单据前缀",
  208. dataIndex : "mn_leadcode",
  209. width : 120.0,
  210. xtype : "",
  211. },
  212. {
  213. text : "单据规则",
  214. dataIndex : "mn_rule",
  215. width : 220.0,
  216. xtype : "",
  217. },{
  218. text : "流水长度",
  219. dataIndex : "mn_number",
  220. width : 120.0,
  221. xtype : "",
  222. }],
  223. keyField:'id',
  224. reqUrl:'/api/commons/number/save'
  225. },
  226. personpower:{
  227. columns: [ {
  228. text : "编号",
  229. dataIndex : "code",
  230. width : 120.0,
  231. xtype : "",
  232. },{
  233. text : "角色名称",
  234. width : 200.0,
  235. dataIndex : "name",
  236. xtype : "",
  237. },
  238. {
  239. text : "角色描述",
  240. dataIndex : "description",
  241. width : 120.0,
  242. xtype : "",
  243. }
  244. ],
  245. keyField:'id',
  246. reqUrl:'/api/account/role/save',
  247. updateUrl:'/api/account/role/update',
  248. },
  249. accountinformation:{
  250. columns:[{
  251. dataIndex:'accountId',
  252. },{
  253. dataIndex: 'roleNames',
  254. },{
  255. dataIndex: 'mobile',
  256. },{
  257. dataIndex: 'email',
  258. }],
  259. reqUrl:'/api/account/account/bind/roles',
  260. },
  261. employee:{
  262. columns: [{
  263. text: '人员编号',
  264. dataIndex: 'em_code',
  265. width: 200
  266. },{
  267. text: '人员名称',
  268. dataIndex: 'em_name',
  269. width: 200
  270. },{
  271. text: '联系电话',
  272. dataIndex: 'em_mobile',
  273. width: 200
  274. },{
  275. text: '邮箱',
  276. dataIndex: 'em_email',
  277. width: 200
  278. },{
  279. text: '人员状态',
  280. dataIndex: 'em_class',
  281. width:90,
  282. xtype: 'actioncolumn',
  283. align : 'center',
  284. items: [{
  285. iconCls:'',
  286. getClass: function(v, meta, rec) {
  287. if(rec.get('em_class')=='正式'){
  288. return 'x-grid-checkcolumn-checked-btn';
  289. }else{
  290. return 'x-grid-checkcolumn-btn';
  291. }
  292. },
  293. handler: function(view, rowIndex, colIndex) {
  294. var rec = view.getStore().getAt(rowIndex);
  295. var type=rec.get('em_class')=='正式'?true:false;
  296. // 禁用/启用
  297. var form = this.ownerCt.ownerCt.ownerCt;
  298. var grid = this.ownerCt.ownerCt;
  299. saas.util.BaseUtil.request({
  300. url: (!type?form._openUrl:form._closeUrl)+'/'+rec.get('id'),
  301. params: '',
  302. method: 'POST',
  303. })
  304. .then(function(localJson) {
  305. if(localJson.success){
  306. saas.util.BaseUtil.showToast('操作成功');
  307. grid.store.load();
  308. }
  309. })
  310. .catch(function(res) {
  311. console.error(res);
  312. saas.util.BaseUtil.showToast('操作失败: ' + res.message);
  313. });
  314. }
  315. }]
  316. }],
  317. keyField:'id',
  318. reqUrl: '/api/document/employee/save',
  319. delUrl: '/api/document/employee/delete'
  320. },
  321. warehouse:{
  322. columns: [{
  323. text: '编号',
  324. dataIndex: 'wh_code',
  325. width: 200
  326. },{
  327. text: '仓库名称',
  328. dataIndex: 'wh_description',
  329. width: 200
  330. },{
  331. text: '类型',
  332. dataIndex: 'wh_type',
  333. width: 200
  334. },{
  335. text: '仓库状态码',
  336. dataIndex: 'wh_status',
  337. hidden:true,
  338. },{
  339. text: '仓库状态',
  340. dataIndex: 'wh_statuscode',
  341. width:90,
  342. xtype: 'actioncolumn',
  343. align : 'center',
  344. items: [{
  345. iconCls:'',
  346. getClass: function(v, meta, rec) {
  347. if(rec.get('wh_statuscode')=='OPEN'){
  348. return 'x-grid-checkcolumn-checked-btn';
  349. }else{
  350. return 'x-grid-checkcolumn-btn';
  351. }
  352. },
  353. handler: function(view, rowIndex, colIndex) {
  354. var rec = view.getStore().getAt(rowIndex);
  355. var type=rec.get('wh_statuscode')=='OPEN'?true:false;
  356. // 禁用/启用
  357. var form = this.ownerCt.ownerCt.ownerCt;
  358. var grid = this.ownerCt.ownerCt;
  359. saas.util.BaseUtil.request({
  360. url: (!type?form._openUrl:form._closeUrl)+'/'+rec.get('id'),
  361. params: '',
  362. method: 'POST',
  363. })
  364. .then(function(localJson) {
  365. if(localJson.success){
  366. saas.util.BaseUtil.showToast('操作成功');
  367. grid.store.load();
  368. }
  369. })
  370. .catch(function(res) {
  371. console.error(res);
  372. saas.util.BaseUtil.showToast('操作失败: ' + res.message);
  373. });
  374. }
  375. }]
  376. }],
  377. keyField:'id',
  378. reqUrl: '/api/document/warehouse/save',
  379. delUrl: '/api/document/warehouse/delete'
  380. }
  381. },
  382. refresh:function(){
  383. var me = this;
  384. var grid = me.items.items[0];
  385. var button = grid.ownerCt.dockedItems.items[0].down('[name='+grid.ownerCt.ownerCt.viewConfig+']');
  386. if(button&&button.xtype!="tbfill"){
  387. button.click();
  388. me.ownerCt.setTitle(button.typeText + '查询');
  389. }
  390. }
  391. })