Kind.js 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  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. //工具类
  14. FormUtil: Ext.create('saas.util.FormUtil'),
  15. BaseUtil: Ext.create('saas.util.BaseUtil'),
  16. defaultType:'',
  17. requires: [
  18. 'Ext.button.Segmented'
  19. ],
  20. tbar: [{
  21. xtype: 'segmentedbutton',
  22. reference: 'dataKind',
  23. value: 'customerkind',
  24. name : 'segmentedbutton',
  25. bind:'{segmented}',
  26. items: [{
  27. name:'customerkind',
  28. text: '客户',
  29. value: 'customerkind',
  30. typeText:'客户类型'
  31. }, {
  32. name:'vendorkind',
  33. text: '供应商',
  34. value: 'vendorkind',
  35. typeText:'供应商类型'
  36. }, {
  37. name:'productkind',
  38. text: '物料',
  39. value: 'productkind',
  40. typeText:'物料类型'
  41. }, {
  42. name:'inoutkind',
  43. text: '收支',
  44. value: 'inoutkind',
  45. typeText:'收支类别'
  46. }],
  47. listeners: {
  48. toggle: 'onKindToggle'
  49. }
  50. },'->',
  51. {
  52. xtype:'button',
  53. text:'新增',
  54. listeners: {
  55. click: 'onAdd'
  56. }
  57. },{
  58. xtype:'button',
  59. text:'刷新',
  60. listeners: {
  61. click: 'onRefresh'
  62. }
  63. }],
  64. items:[{
  65. xtype:'grid',
  66. reference: 'document-kind-Grid',
  67. margin: '10 0 0 0',
  68. flex: 1,
  69. frame:true,
  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. console.log("format:",format);
  150. return Ext.util.Format.number(v, format);
  151. },
  152. flex: 1
  153. },{
  154. text: '当前余额',
  155. dataIndex: 'bk_thisamount',
  156. xtype: 'numbercolumn',
  157. renderer : function(v) {
  158. var arr = (v + '.').split('.');
  159. var xr = (new Array(arr[1].length > 2 ? 2 : arr[1].length)).fill('0');
  160. var format = '0,000.' + xr.join();
  161. console.log("format:",format);
  162. return Ext.util.Format.number(v, format);
  163. },
  164. flex: 1
  165. },{
  166. xtype:'datecolumn',
  167. text: '建账日期',
  168. format:'Y-m-d',
  169. dataIndex: 'bk_date',
  170. flex: 1
  171. }, {
  172. text: '备注',
  173. dataIndex: 'bk_remark',
  174. flex: 1
  175. }],
  176. keyField:'id',
  177. reqUrl: '/api/document/bankinformation/save',
  178. delUrl: '/api/document/bankinformation/delete'
  179. },
  180. inoutkind:{
  181. columns: [{
  182. text: '收支名称',
  183. dataIndex: 'ft_name',
  184. flex: 1
  185. },{
  186. text: '收支类别',
  187. dataIndex: 'ft_kind',
  188. flex: 1
  189. }],
  190. keyField:'id',
  191. reqUrl: '/api/document/fundinouttype/save',
  192. delUrl: '/api/document/fundinouttype/delete'
  193. },
  194. address:{
  195. columns: [{
  196. text: '地址名称',
  197. dataIndex: 'ad_address',
  198. flex: 1
  199. }],
  200. keyField:'id',
  201. reqUrl: '/api/document/address/save',
  202. delUrl: '/api/document/address/delete'
  203. },
  204. maxnumbers:{
  205. columns: [{
  206. text : "单据名称",
  207. width : 200.0,
  208. dataIndex : "mn_caller",
  209. xtype : "",
  210. },
  211. {
  212. text : "单据前缀",
  213. dataIndex : "mn_leadcode",
  214. width : 120.0,
  215. xtype : "",
  216. },
  217. {
  218. text : "单据规则",
  219. dataIndex : "mn_rule",
  220. width : 220.0,
  221. xtype : "",
  222. },{
  223. text : "流水长度",
  224. dataIndex : "mn_number",
  225. width : 120.0,
  226. xtype : "",
  227. }],
  228. keyField:'id',
  229. reqUrl:'/api/commons/number/save'
  230. },
  231. personpower:{
  232. columns: [ {
  233. text : "编号",
  234. dataIndex : "code",
  235. width : 120.0,
  236. xtype : "",
  237. },{
  238. text : "角色名称",
  239. width : 200.0,
  240. dataIndex : "name",
  241. xtype : "",
  242. },
  243. {
  244. text : "角色描述",
  245. dataIndex : "description",
  246. width : 120.0,
  247. xtype : "",
  248. }
  249. ],
  250. keyField:'id',
  251. reqUrl:'/api/account/role/save',
  252. updateUrl:'/api/account/role/update',
  253. },
  254. warehouse:{
  255. columns: [{
  256. text: '编号',
  257. dataIndex: 'wh_code',
  258. width: 200
  259. },{
  260. text: '仓库名称',
  261. dataIndex: 'wh_description',
  262. width: 200
  263. },{
  264. text: '类型',
  265. dataIndex: 'wh_type',
  266. width: 200
  267. },{
  268. text: '仓库状态码',
  269. dataIndex: 'wh_status',
  270. hidden:true,
  271. },{
  272. text: '仓库状态',
  273. dataIndex: 'wh_statuscode',
  274. width:90,
  275. xtype: 'actioncolumn',
  276. align : 'center',
  277. items: [{
  278. iconCls:'',
  279. getClass: function(v, meta, rec) {
  280. if(rec.get('wh_statuscode')=='OPEN'){
  281. return 'x-grid-checkcolumn-checked-btn';
  282. }else{
  283. return 'x-grid-checkcolumn-btn';
  284. }
  285. },
  286. handler: function(view, rowIndex, colIndex) {
  287. var rec = view.getStore().getAt(rowIndex);
  288. var type=rec.get('wh_statuscode')=='OPEN'?true:false;
  289. // 禁用/启用
  290. var form = this.ownerCt.ownerCt.ownerCt;
  291. var grid = this.ownerCt.ownerCt;
  292. form.BaseUtil.request({
  293. url: (!type?form._openUrl:form._closeUrl)+'/'+rec.get('id'),
  294. params: '',
  295. method: 'POST',
  296. })
  297. .then(function(localJson) {
  298. if(localJson.success){
  299. showToast('操作成功');
  300. grid.store.load();
  301. }
  302. })
  303. .catch(function(res) {
  304. console.error(res);
  305. showToast('操作失败: ' + res.message);
  306. });
  307. }
  308. }]
  309. }],
  310. keyField:'id',
  311. reqUrl: '/api/document/warehouse/save',
  312. delUrl: '/api/document/warehouse/delete'
  313. }
  314. },
  315. refresh:function(){
  316. var me = this;
  317. var grid = me.items.items[0];
  318. var button = grid.ownerCt.dockedItems.items[0].down('[name='+grid.ownerCt.ownerCt.viewConfig+']');
  319. if(button&&button.xtype!="tbfill"){
  320. button.click();
  321. me.ownerCt.setTitle(button.typeText + '查询');
  322. }
  323. }
  324. })