| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453 |
- 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);
- });
- },
- });
|