QueryPanel.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. Ext.define('make.view.make.bom.QueryPanel', {
  2. extend: 'saas.view.core.query.QueryPanel',
  3. xtype: 'make-bom-querypanel',
  4. controller: 'make-bom-querypanel',
  5. viewModel: {
  6. extend: 'saas.view.core.query.QueryPanelModel',
  7. data: {
  8. form: {}, // 查询字段记录
  9. addEnable: false, // 显示新增按钮
  10. auditEnable: true, // 显示审核按钮
  11. printEnable: false, // 显示打印按钮
  12. importEnable: true, // 显示导入按钮
  13. exportEnable: true, // 显示导出按钮
  14. closeEnable: false, // 显示关闭按钮
  15. deleteEnable: true, // 显示删除按钮
  16. deleteDisable:false, //删除按钮是否可使用
  17. openAudit:false,//单独显示审核按钮
  18. openUnAudit:false,//单独显示反审核按钮
  19. openEnable:false, //显示开启 针对已取消列表
  20. configurable: true, // 允许列设置
  21. }
  22. },
  23. viewName: 'make-bom-querypanel',
  24. caller: 'Bom',
  25. importUploadPath: '/api/make/bom/saveToFormal',
  26. initComponent: function () {
  27. var me = this;
  28. Ext.apply(this, {
  29. queryFormItems: [ {
  30. xtype: 'condatefield',
  31. name: 'BOM.createTime',
  32. fieldLabel: '日期',
  33. columnWidth: 0.5,
  34. operation: 'between',
  35. },{
  36. xtype: 'multiqueryField',
  37. columnWidth: 0.4,
  38. name: 'multi_query',
  39. querys: {
  40. "Prod": {"field": "bo_mothercode", "dbfinds": [{//物料
  41. from: 'pr_code',
  42. to: 'bo_mothercode'
  43. },{
  44. from: 'pr_detail',
  45. to: 'pr_detail'
  46. }]},
  47. //工作中心
  48. "BillCode": {"field": "bo_wcname" ,"desc": "工作中心"},
  49. "Emp":{"field": "BOM.creatorName", "dbfinds": [{
  50. from: 'em_name',
  51. to: 'BOM.creatorName'
  52. }]},
  53. }
  54. }],
  55. moreQueryFormItems: [{
  56. xtype: 'condatefield',
  57. name: 'bom.createTime',
  58. fieldLabel: '单据日期',
  59. value:1,
  60. columnWidth: 1
  61. }, {
  62. xtype: 'productDbfindTrigger',
  63. name: 'bo_mothercode',
  64. fieldLabel: '物料编号'
  65. },{
  66. xtype: 'textfield',
  67. name: 'pr_detail',
  68. fieldLabel: '产品名称',
  69. readOnly: true,
  70. }, {
  71. xtype: 'textfield',
  72. name: 'pr_orispeccode',
  73. fieldLabel: '产品型号',
  74. readOnly: true,
  75. }, {
  76. xtype: "remotecombo",
  77. name: "pr_brand",
  78. fieldLabel: "厂家/品牌",
  79. storeUrl: '/api/document/productbrand/getCombo',
  80. editable: false,
  81. hiddenBtn:true
  82. },{
  83. xtype: 'remotecombo',
  84. name: "bo_wcname",
  85. fieldLabel: "工作中心",
  86. storeUrl: '/api/document/workcenter/getCombo',
  87. editable: false,
  88. hiddenBtn:true
  89. },{
  90. xtype: 'combobox',
  91. name: 'bo_statuscode',
  92. fieldLabel: '审核状态',
  93. queryMode: 'local',
  94. displayField: 'bo_status',
  95. valueField: 'bo_statuscode',
  96. emptyText :'全部',
  97. editable:false,
  98. store: Ext.create('Ext.data.ArrayStore', {
  99. fields: ['bo_statuscode', 'bo_status'],
  100. data: [
  101. ["ALL", "全部"],
  102. ["AUDITED", "已审核"],
  103. ["UNAUDITED", "未审核"]
  104. ]
  105. }),
  106. getCondition: function(value) {
  107. if(value == 'ALL') {
  108. return '1=1';
  109. }else {
  110. return 'bo_statuscode=\'' + value + '\'';
  111. }
  112. }
  113. }, {
  114. xtype: 'employeeDbfindTrigger',
  115. name: 'creatorName',
  116. fieldLabel: '录入人',
  117. emptyText:'请输入账户名称或姓名',
  118. getCondition: function(value) {
  119. if(!value) {
  120. return '1=1';
  121. }else {
  122. return 'bom.creatorName like\'%' + value + '%\'';
  123. }
  124. }
  125. },{
  126. xtype: 'employeeDbfindTrigger',
  127. name: 'bo_auditman',
  128. fieldLabel: '审核人',
  129. emptyText:'请输入账户名称或姓名',
  130. }],
  131. queryGridConfig: {
  132. idField: 'id',
  133. codeField: 'bo_code',
  134. mainIdField:'_id',
  135. addTitle: 'BOM',
  136. addXtype: 'make-bom-formpanel',
  137. defaultCondition: me.defaultCondition,
  138. //baseVastUrl: '/api/make/bom/',
  139. baseVastUrl: me.baseVastUrl,
  140. caller: 'Bom',
  141. defaultBtns:[{//'->',
  142. text: '新增',
  143. cls:'x-formpanel-btn-blue',
  144. handler: 'onAddClick',
  145. hidden: true,
  146. bind: {
  147. hidden: '{!addEnable}'
  148. }
  149. }, {
  150. text: '导入',
  151. handler: 'onImport',
  152. hidden: true,
  153. bind: {
  154. hidden: '{!importEnable}'
  155. }
  156. }, {
  157. text: '审核',
  158. xtype: 'button',
  159. handler: me.onAudit,
  160. menu: {
  161. cls:'x-query-menu',
  162. anchor: '100%',
  163. items: [{
  164. text:'反审核',
  165. handler:function(){
  166. me.onUnAudit(this)
  167. }
  168. }],
  169. listeners: {
  170. 'mouseleave':function(enu){
  171. this.hide();
  172. }
  173. }
  174. },
  175. hidden: true,
  176. bind: {
  177. hidden: '{!auditEnable}'
  178. }
  179. },{
  180. text: '审核',
  181. handler:me.onAudit,
  182. hidden: true,
  183. bind: {
  184. hidden: '{!openAudit}'
  185. }
  186. },{
  187. text: '反审核',
  188. handler:me.onUnAudit,
  189. hidden: true,
  190. bind: {
  191. hidden: '{!openUnAudit}'
  192. }
  193. },{
  194. text: '取消',
  195. handler:me.onCloseOrder,
  196. hidden: true,
  197. bind: {
  198. hidden: '{!cancelEnable}'
  199. }
  200. },{
  201. text: '开启',
  202. handler:me.onOpenOrder,
  203. hidden: true,
  204. bind: {
  205. hidden: '{!openEnable}'
  206. }
  207. },{
  208. text: '取消',
  209. handler: me.onCloseOrder,
  210. menu: {
  211. cls:'x-query-menu',
  212. width: 80,
  213. items: [{
  214. text:'开启',
  215. handler:function(){
  216. me.onOpenOrder(this)
  217. }
  218. }],
  219. listeners: {
  220. 'mouseleave':function(enu){
  221. this.hide();
  222. }
  223. }
  224. },
  225. hidden: true,
  226. bind: {
  227. hidden: '{!closeEnable}'
  228. }
  229. }, {
  230. text: '导出',
  231. handler: me.onExport,
  232. hidden: true,
  233. bind: {
  234. hidden: '{!exportEnable}'
  235. }
  236. }, {
  237. text: '删除',
  238. handler: me.onDelete,
  239. hidden: true,
  240. bind: {
  241. hidden: '{!deleteEnable}',
  242. disabled: '{deleteDisable}'
  243. }
  244. },{
  245. text: '删除全部',
  246. handler: me.onDeleteAll,
  247. hidden: false,
  248. }],
  249. baseColumn: [{
  250. text: 'id',
  251. dataIndex: 'id',
  252. hidden: true,
  253. xtype: 'numbercolumn'
  254. }, {
  255. text: '单据编号',
  256. dataIndex: 'bo_code',
  257. width: 150
  258. }, {
  259. text: '产品编号',
  260. dataIndex: 'bo_mothercode',
  261. width: 150
  262. }, {
  263. text: '产品名称',
  264. dataIndex: 'bo_mothername',
  265. width: 150
  266. },{
  267. text: '产品型号',
  268. dataIndex: 'pr_orispeccode',
  269. width: 150,
  270. renderer: saas.util.RenderUtil['renderer_prod']
  271. }, {
  272. text: '单位',
  273. dataIndex: 'pr_unit',
  274. width: 150
  275. }, {
  276. text: '工作中心',
  277. dataIndex: 'bo_wcname',
  278. width: 110
  279. },{
  280. text: '状态',
  281. dataIndex: 'bo_status',
  282. width: 110
  283. },{
  284. text: '制单人',
  285. dataIndex: 'creatorName',
  286. width: 100,
  287. }],
  288. relativeColumn: [{
  289. text: 'id',
  290. dataIndex: 'id',
  291. hidden: true,
  292. xtype: 'numbercolumn'
  293. }, {
  294. text: '单据编号',
  295. dataIndex: 'bo_code',
  296. width: 150
  297. }, {
  298. text: '产品编号',
  299. dataIndex: 'bo_mothercode',
  300. width: 150
  301. }, {
  302. text: '产品名称',
  303. dataIndex: 'bo_mothername',
  304. width: 150
  305. },{
  306. text: '产品型号',
  307. dataIndex: 'pr_orispeccode',
  308. width: 150
  309. }, {
  310. text: '单位',
  311. dataIndex: 'pr_unit',
  312. width: 150
  313. }, {
  314. text: '工作中心',
  315. dataIndex: 'bo_wcname',
  316. width: 110
  317. },{
  318. text: '状态',
  319. dataIndex: 'bo_status',
  320. width: 110
  321. },{
  322. text: '制单人',
  323. dataIndex: 'creatorName',
  324. width: 100,
  325. }]
  326. }
  327. });
  328. this.callParent(arguments);
  329. },
  330. onDeleteAll: function (btns) {
  331. var me = this;
  332. var grid = btns.up('grid');
  333. var deleteMsg ="所有的BOM数据都将删除,确定要全部删除?";
  334. saas.util.BaseUtil.warnMsg(deleteMsg,function(btn){
  335. if(btn == 'yes'){
  336. var url = me.ownerCt.ownerCt.baseVastUrl+'deleteAll' , bench = me.up('core-bench-query');
  337. if(bench && bench.caller) {
  338. url = url+'?caller='+bench.caller;
  339. }
  340. saas.util.BaseUtil.request({
  341. url: url,
  342. method: 'POST',
  343. async:false
  344. })
  345. .then(function(res) {
  346. if(res.data){
  347. saas.util.BaseUtil.showSuccessToast(res.data);
  348. }else{
  349. saas.util.BaseUtil.showSuccessToast('删除全部BOM操作成功');
  350. }
  351. me.ownerCt.ownerCt.store.removeAll()
  352. })
  353. .catch(function(res) {
  354. console.error(res);
  355. saas.util.BaseUtil.showErrorToast(('删除全部BOM操作失败: ') + res.message);
  356. });
  357. }
  358. });
  359. },
  360. onAudit: function(me){
  361. me.up('grid').vastOperation("batchAudit",'审核');
  362. },
  363. onUnAudit:function(me){
  364. me.up('grid').vastOperation("batchUnAudit",'反审核');
  365. },
  366. onDelete: function (btns) {
  367. var grid = btns.up('grid');
  368. var data = grid.getGridSelected();
  369. var deleteMsg =grid.addTitle?"删除的"+grid.addTitle+"将不能恢复,请确认是否删除?":"是否删除所选单据?";
  370. if(data&&data.length>0){
  371. saas.util.BaseUtil.warnMsg(deleteMsg,function(btn){
  372. if(btn == 'yes'){
  373. grid.vastOperation("batchDelete");
  374. }
  375. });
  376. }else{
  377. saas.util.BaseUtil.showErrorToast('请勾选至少一条明细。');
  378. }
  379. },
  380. vastOperation :function(type,msg){
  381. var me = this;
  382. var data = me.getGridSelected(type);
  383. var queryPanel = me.up('core-query-querypanel'),
  384. mode = queryPanel.getQueryMode();
  385. if(data&&data.length>0){
  386. var params = JSON.stringify({baseDTOs:data});
  387. if(type=='batchClose' || type=='batchOpen' || type=='batchDelete'){
  388. params = JSON.stringify({baseDTOs:data,mode:mode});
  389. }
  390. var url = me.baseVastUrl+type , bench = me.up('core-bench-query');
  391. if(bench && bench.caller) {
  392. url = url+'?caller='+bench.caller;
  393. }
  394. saas.util.BaseUtil.request({
  395. url: url,
  396. params: params,
  397. method: 'POST',
  398. async:false
  399. })
  400. .then(function(res) {
  401. if(res.data){
  402. saas.util.BaseUtil.showSuccessToast(res.data);
  403. }else{
  404. saas.util.BaseUtil.showSuccessToast(msg?msg + '成功':'操作成功');
  405. }
  406. me.store.load();
  407. me.selModel.deselectAll();
  408. })
  409. .catch(function(res) {
  410. console.error(res);
  411. saas.util.BaseUtil.showErrorToast((msg?msg + '失败: ':'操作失败: ') + res.message);
  412. });
  413. }else{
  414. saas.util.BaseUtil.showErrorToast('请勾选至少一条明细。');
  415. }
  416. },
  417. onExport: function () {
  418. var grid = this.up('grid');
  419. //导出接口权限设置
  420. var url = '/api/commons/'+grid.caller+'/export';
  421. saas.util.BaseUtil.request({
  422. url: url,
  423. params: '',
  424. method: 'GET',
  425. })
  426. .then(function(localJson) {
  427. if(localJson.success){
  428. grid.store.exportPageSize = 5000;
  429. grid.store.exportNumber = 1;
  430. grid.store.load(function(records, operation, success) {
  431. grid.saveDocumentAs({
  432. type: 'xlsx',
  433. title: grid.addTitle + '列表',
  434. fileName: grid.addTitle + '列表'+ Ext.Date.format(new Date(),'Y-m-d_H-i-s') +'.xlsx',
  435. });
  436. grid.store.exportPageSize = null;
  437. grid.store.exportNumber = null;
  438. grid.store.load(function(records, operation, success) {
  439. });
  440. });
  441. }
  442. })
  443. .catch(function(e) {
  444. saas.util.BaseUtil.showErrorToast('导出失败: ' + e.message);
  445. });
  446. },
  447. });