Kind.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. 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. xtype : "",
  208. },
  209. {
  210. text : "单据前缀",
  211. dataIndex : "mn_leadcode",
  212. width : 120.0,
  213. xtype : "",
  214. },
  215. {
  216. text : "单据规则",
  217. dataIndex : "mn_rule",
  218. width : 220.0,
  219. xtype : "",
  220. },{
  221. text : "流水长度",
  222. dataIndex : "mn_number",
  223. width : 120.0,
  224. xtype : "",
  225. }],
  226. keyField:'id',
  227. reqUrl:'/api/commons/number/save'
  228. },
  229. personpower:{
  230. columns: [ {
  231. text : "编号",
  232. dataIndex : "code",
  233. width : 120.0,
  234. xtype : "",
  235. },{
  236. text : "角色名称",
  237. width : 200.0,
  238. dataIndex : "name",
  239. xtype : "",
  240. },
  241. {
  242. text : "角色描述",
  243. dataIndex : "description",
  244. width : 120.0,
  245. xtype : "",
  246. }
  247. ],
  248. keyField:'id',
  249. reqUrl:'/api/account/role/save',
  250. updateUrl:'/api/account/role/update',
  251. },
  252. warehouse:{
  253. columns: [{
  254. text: '编号',
  255. dataIndex: 'wh_code',
  256. width: 200
  257. },{
  258. text: '仓库名称',
  259. dataIndex: 'wh_description',
  260. width: 200
  261. },{
  262. text: '类型',
  263. dataIndex: 'wh_type',
  264. width: 200
  265. },{
  266. text: '仓库状态码',
  267. dataIndex: 'wh_status',
  268. hidden:true,
  269. },{
  270. text: '仓库状态',
  271. dataIndex: 'wh_statuscode',
  272. width:90,
  273. xtype: 'actioncolumn',
  274. align : 'center',
  275. items: [{
  276. iconCls:'',
  277. getClass: function(v, meta, rec) {
  278. if(rec.get('wh_statuscode')=='OPEN'){
  279. return 'x-grid-checkcolumn-checked-btn';
  280. }else{
  281. return 'x-grid-checkcolumn-btn';
  282. }
  283. },
  284. handler: function(view, rowIndex, colIndex) {
  285. var rec = view.getStore().getAt(rowIndex);
  286. var type=rec.get('wh_statuscode')=='OPEN'?true:false;
  287. // 禁用/启用
  288. var form = this.ownerCt.ownerCt.ownerCt;
  289. var grid = this.ownerCt.ownerCt;
  290. form.BaseUtil.request({
  291. url: (!type?form._openUrl:form._closeUrl)+'/'+rec.get('id'),
  292. params: '',
  293. method: 'POST',
  294. })
  295. .then(function(localJson) {
  296. if(localJson.success){
  297. showToast('操作成功');
  298. grid.store.load();
  299. }
  300. })
  301. .catch(function(res) {
  302. console.error(res);
  303. showToast('操作失败: ' + res.message);
  304. });
  305. }
  306. }]
  307. }],
  308. keyField:'id',
  309. reqUrl: '/api/document/warehouse/save',
  310. delUrl: '/api/document/warehouse/delete'
  311. }
  312. },
  313. refresh:function(){
  314. var me = this;
  315. var grid = me.items.items[0];
  316. var button = grid.ownerCt.dockedItems.items[0].down('[name='+grid.ownerCt.ownerCt.viewConfig+']');
  317. if(button&&button.xtype!="tbfill"){
  318. button.click();
  319. me.ownerCt.setTitle(button.typeText + '查询');
  320. }
  321. }
  322. })