Ext.define('make.view.make.bom.QueryPanel', { extend: 'saas.view.core.query.QueryPanel', xtype: 'make-bom-querypanel', controller: 'make-bom-querypanel', viewModel: { extend: 'saas.view.core.query.QueryPanelModel', data: { form: {}, // 查询字段记录 addEnable: false, // 显示新增按钮 auditEnable: true, // 显示审核按钮 printEnable: false, // 显示打印按钮 importEnable: true, // 显示导入按钮 exportEnable: true, // 显示导出按钮 closeEnable: false, // 显示关闭按钮 deleteEnable: true, // 显示删除按钮 deleteDisable:false, //删除按钮是否可使用 openAudit:false,//单独显示审核按钮 openUnAudit:false,//单独显示反审核按钮 openEnable:false, //显示开启 针对已取消列表 configurable: true, // 允许列设置 } }, viewName: 'make-bom-querypanel', caller: 'Bom', importUploadPath: '/api/make/bom/saveToFormal', initComponent: function () { var me = this; Ext.apply(this, { queryFormItems: [ { xtype: 'condatefield', name: 'BOM.createTime', fieldLabel: '日期', columnWidth: 0.5, operation: 'between', },{ xtype: 'multiqueryField', columnWidth: 0.4, name: 'multi_query', querys: { "Prod": {"field": "bo_mothercode", "dbfinds": [{//物料 from: 'pr_code', to: 'bo_mothercode' },{ from: 'pr_detail', to: 'pr_detail' }]}, //工作中心 "BillCode": {"field": "bo_wcname" ,"desc": "工作中心"}, "Emp":{"field": "BOM.creatorName", "dbfinds": [{ from: 'em_name', to: 'BOM.creatorName' }]}, } }], moreQueryFormItems: [{ xtype: 'condatefield', name: 'bom.createTime', fieldLabel: '单据日期', value:1, columnWidth: 1 }, { xtype: 'productDbfindTrigger', name: 'bo_mothercode', fieldLabel: '物料编号' },{ xtype: 'textfield', name: 'pr_detail', fieldLabel: '产品名称', readOnly: true, }, { xtype: 'textfield', name: 'pr_orispeccode', fieldLabel: '产品型号', readOnly: true, }, { xtype: "remotecombo", name: "pr_brand", fieldLabel: "厂家/品牌", storeUrl: '/api/document/productbrand/getCombo', editable: false, hiddenBtn:true },{ xtype: 'remotecombo', name: "bo_wcname", fieldLabel: "工作中心", storeUrl: '/api/document/workcenter/getCombo', editable: false, hiddenBtn:true },{ xtype: 'combobox', name: 'bo_statuscode', fieldLabel: '审核状态', queryMode: 'local', displayField: 'bo_status', valueField: 'bo_statuscode', emptyText :'全部', editable:false, store: Ext.create('Ext.data.ArrayStore', { fields: ['bo_statuscode', 'bo_status'], data: [ ["ALL", "全部"], ["AUDITED", "已审核"], ["UNAUDITED", "未审核"] ] }), getCondition: function(value) { if(value == 'ALL') { return '1=1'; }else { return 'bo_statuscode=\'' + value + '\''; } } }, { xtype: 'employeeDbfindTrigger', name: 'creatorName', fieldLabel: '录入人', emptyText:'请输入账户名称或姓名', getCondition: function(value) { if(!value) { return '1=1'; }else { return 'bom.creatorName like\'%' + value + '%\''; } } },{ xtype: 'employeeDbfindTrigger', name: 'bo_auditman', fieldLabel: '审核人', emptyText:'请输入账户名称或姓名', }], queryGridConfig: { idField: 'id', codeField: 'bo_code', mainIdField:'_id', addTitle: 'BOM', addXtype: 'make-bom-formpanel', defaultCondition: me.defaultCondition, //baseVastUrl: '/api/make/bom/', baseVastUrl: me.baseVastUrl, caller: 'Bom', defaultBtns:[{//'->', text: '新增', cls:'x-formpanel-btn-blue', handler: 'onAddClick', hidden: true, bind: { hidden: '{!addEnable}' } }, { text: '导入', handler: 'onImport', hidden: true, bind: { hidden: '{!importEnable}' } }, { text: '审核', xtype: 'button', handler: me.onAudit, menu: { cls:'x-query-menu', anchor: '100%', items: [{ text:'反审核', handler:function(){ me.onUnAudit(this) } }], listeners: { 'mouseleave':function(enu){ this.hide(); } } }, hidden: true, bind: { hidden: '{!auditEnable}' } },{ text: '审核', handler:me.onAudit, hidden: true, bind: { hidden: '{!openAudit}' } },{ text: '反审核', handler:me.onUnAudit, hidden: true, bind: { hidden: '{!openUnAudit}' } },{ text: '取消', handler:me.onCloseOrder, hidden: true, bind: { hidden: '{!cancelEnable}' } },{ text: '开启', handler:me.onOpenOrder, hidden: true, bind: { hidden: '{!openEnable}' } },{ text: '取消', handler: me.onCloseOrder, menu: { cls:'x-query-menu', width: 80, items: [{ text:'开启', handler:function(){ me.onOpenOrder(this) } }], listeners: { 'mouseleave':function(enu){ this.hide(); } } }, hidden: true, bind: { hidden: '{!closeEnable}' } }, { text: '导出', handler: me.onExport, hidden: true, bind: { hidden: '{!exportEnable}' } }, { text: '删除', handler: me.onDelete, hidden: true, bind: { hidden: '{!deleteEnable}', disabled: '{deleteDisable}' } },{ text: '删除全部', handler: me.onDeleteAll, hidden: false, }], baseColumn: [{ text: 'id', dataIndex: 'id', hidden: true, xtype: 'numbercolumn' }, { text: '单据编号', dataIndex: 'bo_code', width: 150 }, { text: '产品编号', dataIndex: 'bo_mothercode', width: 150 }, { text: '产品名称', dataIndex: 'bo_mothername', width: 150 },{ text: '产品型号', dataIndex: 'pr_orispeccode', width: 150, renderer: saas.util.RenderUtil['renderer_prod'] }, { text: '单位', dataIndex: 'pr_unit', width: 150 }, { text: '工作中心', dataIndex: 'bo_wcname', width: 110 },{ text: '状态', dataIndex: 'bo_status', width: 110 },{ text: '制单人', dataIndex: 'creatorName', width: 100, }], relativeColumn: [{ text: 'id', dataIndex: 'id', hidden: true, xtype: 'numbercolumn' }, { text: '单据编号', dataIndex: 'bo_code', width: 150 }, { text: '产品编号', dataIndex: 'bo_mothercode', width: 150 }, { text: '产品名称', dataIndex: 'bo_mothername', width: 150 },{ text: '产品型号', dataIndex: 'pr_orispeccode', width: 150 }, { text: '单位', dataIndex: 'pr_unit', width: 150 }, { text: '工作中心', dataIndex: 'bo_wcname', width: 110 },{ text: '状态', dataIndex: 'bo_status', width: 110 },{ text: '制单人', dataIndex: 'creatorName', width: 100, }] } }); this.callParent(arguments); }, onDeleteAll: function (btns) { var me = this; var grid = btns.up('grid'); var deleteMsg ="所有的BOM数据都将删除,确定要全部删除?"; saas.util.BaseUtil.warnMsg(deleteMsg,function(btn){ if(btn == 'yes'){ var url = me.ownerCt.ownerCt.baseVastUrl+'deleteAll' , bench = me.up('core-bench-query'); if(bench && bench.caller) { url = url+'?caller='+bench.caller; } saas.util.BaseUtil.request({ url: url, method: 'POST', async:false }) .then(function(res) { if(res.data){ saas.util.BaseUtil.showSuccessToast(res.data); }else{ saas.util.BaseUtil.showSuccessToast('删除全部BOM操作成功'); } me.ownerCt.ownerCt.store.removeAll() }) .catch(function(res) { console.error(res); saas.util.BaseUtil.showErrorToast(('删除全部BOM操作失败: ') + res.message); }); } }); }, onAudit: function(me){ me.up('grid').vastOperation("batchAudit",'审核'); }, onUnAudit:function(me){ me.up('grid').vastOperation("batchUnAudit",'反审核'); }, onDelete: function (btns) { var grid = btns.up('grid'); var data = grid.getGridSelected(); var deleteMsg =grid.addTitle?"删除的"+grid.addTitle+"将不能恢复,请确认是否删除?":"是否删除所选单据?"; if(data&&data.length>0){ saas.util.BaseUtil.warnMsg(deleteMsg,function(btn){ if(btn == 'yes'){ grid.vastOperation("batchDelete"); } }); }else{ saas.util.BaseUtil.showErrorToast('请勾选至少一条明细。'); } }, vastOperation :function(type,msg){ var me = this; var data = me.getGridSelected(type); var queryPanel = me.up('core-query-querypanel'), mode = queryPanel.getQueryMode(); if(data&&data.length>0){ var params = JSON.stringify({baseDTOs:data}); if(type=='batchClose' || type=='batchOpen' || type=='batchDelete'){ params = JSON.stringify({baseDTOs:data,mode:mode}); } var url = me.baseVastUrl+type , bench = me.up('core-bench-query'); if(bench && bench.caller) { url = url+'?caller='+bench.caller; } saas.util.BaseUtil.request({ url: url, params: params, method: 'POST', async:false }) .then(function(res) { if(res.data){ saas.util.BaseUtil.showSuccessToast(res.data); }else{ saas.util.BaseUtil.showSuccessToast(msg?msg + '成功':'操作成功'); } me.store.load(); me.selModel.deselectAll(); }) .catch(function(res) { console.error(res); saas.util.BaseUtil.showErrorToast((msg?msg + '失败: ':'操作失败: ') + res.message); }); }else{ saas.util.BaseUtil.showErrorToast('请勾选至少一条明细。'); } }, onExport: function () { var grid = this.up('grid'); //导出接口权限设置 var url = '/api/commons/'+grid.caller+'/export'; saas.util.BaseUtil.request({ url: url, params: '', method: 'GET', }) .then(function(localJson) { if(localJson.success){ grid.store.exportPageSize = 5000; grid.store.exportNumber = 1; grid.store.load(function(records, operation, success) { grid.saveDocumentAs({ type: 'xlsx', title: grid.addTitle + '列表', fileName: grid.addTitle + '列表'+ Ext.Date.format(new Date(),'Y-m-d_H-i-s') +'.xlsx', }); grid.store.exportPageSize = null; grid.store.exportNumber = null; grid.store.load(function(records, operation, success) { }); }); } }) .catch(function(e) { saas.util.BaseUtil.showErrorToast('导出失败: ' + e.message); }); }, });