123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- Ext.define('saas.view.make.bom.BomCompareGrid', {
- extend: 'Ext.grid.Panel',
- xtype: 'make-bom-bomcomparegrid',
- requires: [
- 'Ext.grid.plugin.Exporter'
- ],
- cls: 'core-base-gridpanel',
- plugins: [{
- ptype: 'gridexporter',
- }, {
- ptype: 'menuclipboard'
- }, {
- ptype: 'cellediting',
- clicksToEdit: 1
- }],
- layout: 'fit',
- border: 1,
- width: '100%',
- loadMask: true,
- columns: [{
- text: '物料编号',
- dataIndex: 'bc_soncode',
- width: 180
- }, {
- text: '物料名称',
- dataIndex: 'pr_detail',
- width: 150
- }, {
- text: '型号',
- dataIndex: 'pr_orispeccode',
- width: 200
- }, {
- text: '单位',
- dataIndex: 'pr_unit',
- width: 65
- }, {
- text: '产品编号1',
- dataIndex: 'bc_code1',
- width: 150
- }, {
- text: '产品编号2',
- dataIndex: 'bc_code2',
- width: 150
- }, {
- text: '产品编号3',
- dataIndex: 'bc_code3',
- width: 150
- }, {
- text: '产品编号4',
- dataIndex: 'bc_code4',
- width: 150
- }, {
- text: '产品编号5',
- dataIndex: 'bc_code5',
- width: 150
- }, {
- text: '产品位号1',
- dataIndex: 'bc_location1',
- width: 150
- }, {
- text: '产品位号2',
- dataIndex: 'bc_location2',
- width: 150
- }, {
- text: '产品位号3',
- dataIndex: 'bc_location3',
- width: 150
- }, {
- text: '产品位号4',
- dataIndex: 'bc_location4',
- width: 150
- }, {
- text: '产品位号5',
- dataIndex: 'bc_location5',
- width: 150
- }],
- initComponent: function () {
- var me = this;
- var fields = me.columns.map(column => column.dataIndex);
- me.store = Ext.create('Ext.data.Store', {
- fields: fields,
- autoLoad: true,
- data: []
- });
- Ext.apply(me, {
- dockedItems: [{
- xtype: 'toolbar',
- dock: 'top',
- items: [{
- xtype: 'checkbox',
- name: 'single',
- columnWidth: 0.3,
- margin: '0 5 0 5',
- isFilter: true,
- boxLabel: '单阶对比',
- checked: false,
- bind:'{single}',
- getFilter: function () {
- },
- listeners: {
- change: function () {
- }
- }
- }, {
- xtype: 'checkbox',
- name: 'differ',
- boxLabel: '只显示有差异物料',
- checked: false,
- margin: '0 5 0 5',
- columnWidth: 0.3,
- bind:'{differ}',
- getFilter: function () {
- },
- listeners: {
- change: function () {
- }
- }
- }, {
- xtype: 'checkbox',
- name: 'noCompareLocation',
- boxLabel: '不考虑位号',
- checked: false,
- margin: '0 5 0 5',
- columnWidth: 0.3,
- bind:'{noCompareLocation}',
- getFilter: function () {
- },
- listeners: {
- change: function () {
- }
- }
- }, '->', {
- text: '查询',
- cls: 'x-formpanel-btn-blue',
- handler: me.onQuery
- }, {
- text: '导出',
- handler: me.onExport
- }]
- }]
- });
- me.callParent(arguments);
- },
- onQuery: function () {
- var grid = this.ownerCt.ownerCt;
- panel = this.up('make-bom-bomcompare'),
- vm = panel.getViewModel();
- vmCodes = panel.getViewModel().get("form");
- var codes = [];
- for (var index in vmCodes) {
- var da = vmCodes[index];
- if("" != da && null != da && codes.indexOf(da) == -1){
- codes.push(da);
- }
- }
- if(codes.length == 0){
- saas.util.BaseUtil.showErrorToast("请选择需要对比的产品编号");
- }
- var params = JSON.stringify( {codes:codes.toString(),differ:vm.get('differ'),single:vm.get('single'),noCompareLocation:vm.get('noCompareLocation')});
- panel.setLoading(true);
- saas.util.BaseUtil.request({
- url: '/api/make/bom/bomCompare',
- params : params,
- method: 'POST',
- })
- .then(function (localJson) {
- panel.setLoading(false);
- if (localJson.success) {
- grid.store.loadData(localJson.data);
- }
- })
- .catch(function (e) {
- panel.setLoading(false);
- saas.util.BaseUtil.showErrorToast('对比失败 ' + e.message);
- });
- },
- onExport: function () {
- var grid = this.ownerCt.ownerCt;
- var cfg = {
- type: 'xlsx',
- title: 'BOM差异比对',
- fileName: 'BOM差异比对' + Ext.Date.format(new Date(), 'Y-m-d_H-i-s') + '.xlsx'
- };
- grid.setLoading(true);
- grid.saveDocumentAs(cfg);
- Ext.defer(function () {
- grid.setLoading(false);
- }, 5000);
- }
- });
|