123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- Ext.define('saas.view.selfmakebalance-Gridpanel', {
- extend: 'Ext.grid.Panel',
- xtype: 'sale-selfmakebalance-gridpanel',
- requires: [
- 'Ext.grid.plugin.Exporter'
- ],
- cls: 'core-base-gridpanel',
- plugins: [{
- ptype: 'gridexporter',
- }, {
- ptype: 'menuclipboard'
- }, {
- ptype: 'cellediting',
- clicksToEdit: 1
- }],
- layout: 'fit',
- //基础属性
- border: 1,
- anchor: '100% 70%',
- loadMask: true,
- showIndex: true,
- columnWidth: 1.0,
- rootProperty: 'data',
- selModel: {
- checkOnly: true,
- type: 'checkboxmodel'
- },
- viewConfig: {
- getRowClass: function (record) {
- return record.get('hasAuditedBom') ? null : 'x-noauditedbom-2';
- }
- },
- calcuMakeBalance: false,
- // idField: 'id',
- // turnQtyField: 'mr_thisqty',
- columns: [{
- text: '本次数量',
- xtype: 'widgetcolumn',
- dataIndex: 'thisQty',
- width: 110,
- widget: {
- xtype: "numberfield",
- cls: 'widget-number',
- decimalPrecision: 8,
- minValue: 0,
- bind: '{record.thisQty}'
- }
- }, {
- text: '计划开工日期',
- xtype: 'widgetcolumn',
- dataIndex: 'planBeginDate',
- width: 150,
- widget: {
- xtype: "datefield",
- cls: 'widget-date',
- format: 'Y-m-d',
- bind: '{record.planBeginDate}'
- }
- }, {
- text: '物料id',
- dataIndex: 'prId',
- hidden: true
- }, {
- text: '物料编号',
- dataIndex: 'prCode',
- width: 150
- }, {
- text: '物料名称',
- dataIndex: 'prDetail',
- width: 150
- }, {
- text: '型号',
- dataIndex: 'prOrispeccode',
- width: 200
- }, {
- text: '供需平衡',
- dataIndex: 'balanceQty'
- }, {
- text: '需求',
- columns: [{
- text: '总需求',
- dataIndex: 'needQty',
- }, {
- text: '备货未核销',
- dataIndex: 'unClashQty',
- }, {
- text: '订单未发货',
- dataIndex: 'unSendQty',
- }, {
- text: '工单未领料',
- dataIndex: 'unPickQty',
- }, {
- text: '安全库存',
- dataIndex: 'safeStockQty',
- }]
- }, {
- text: '供应',
- columns: [{
- text: '总供应',
- dataIndex: 'supplyQty',
- }, {
- text: '良品库存',
- dataIndex: 'greatTotal',
- }, {
- text: '采购未交',
- dataIndex: 'purUnInQty',
- }, {
- text: '工单未完工',
- dataIndex: 'unMakeInQty',
- }]
- }],
- initComponent: function () {
- var me = this;
- me.store = Ext.create('Ext.data.Store', {
- autoLoad: false,
- data: [],
- listeners: {
- beforeload: function (store, op) {
- var gridpanel = me,
- params = {},
- keyWords = me.ownerCt.dockedItems.items[0].down('[name="keyWords"]').value;
- var params = JSON.stringify({ keyWords: keyWords, calcuMakeBalance: gridpanel.calcuMakeBalance });
- me.setLoading(true);
- saas.util.BaseUtil.request({
- url: '/api/make/makeBalance/list',
- method: 'POST',
- params: params
- })
- .then(function (localJson) {
- me.setLoading(false);
- if (localJson.success) {
- gridpanel.getStore().loadData(localJson.data);
- }
- })
- .catch(function (e) {
- me.setLoading(false);
- saas.util.BaseUtil.showErrorToast('计算失败: ' + e.message);
- });
- }
- }
- });
- Ext.apply(me, {
- dockedItems: [{
- xtype: 'toolbar',
- dock: 'top',
- items: [{
- text: '平衡计算',
- handler: function (b) {
- me.calcuMakeBalance = true;
- me.getStore().load();
- me.calcuMakeBalance = false;
- },
- }, {
- xtype: 'checkbox',
- name: '',
- columnWidth: 0.3,
- margin: '0 0 0 10',
- isFilter: true,
- boxLabel: '只显示供需平衡为负数的物料',
- checked: false,
- getFilter: function () {
- var me = this;
- let value = me.value, filter = {};
- if (value) {//已勾选
- filter = {
- filterFn: function (rec) {
- return rec.get('balanceQty') < 0;
- },
- anyMatch: true,
- caseSensitive: false
- };
- }
- return filter;
- },
- listeners: {
- change: function () {
- me.onFilter();
- }
- }
- }, {
- xtype: 'radiogroup',
- name: 'redio_vend',
- width: 200,
- margin: '0 0 0 80',
- cls: 'vendRadiogroup',
- simpleValue: true,
- items: [
- { boxLabel: '单级', inputValue: 'SINGLE', checked: true },
- { boxLabel: '多级', inputValue: 'MULTI' }
- ]
- }, '->',
- {
- iconCls: 'x-fa fa-question-circle',
- reference: 'qMark',
- name: 'qMark',
- cls: 'qMark',
- ui: 'header',
- tooltip: {
- text: '底色标识部分产品无BOM或者BOM未审核',
- anchor: 'top',
- title: '提示:',
- width: 350,
- dismissDelay: 7200000
- }
- }, {
- text: '生成工单',
- cls: 'x-formpanel-btn-blue',
- handler: function (btn) {
- me.turnMake();
- }
- }, {
- text: '导出',
- handler: me.onExport
- }]
- }]
- });
- me.callParent(arguments);
- },
- turnMake: function () {
- var me = this,
- makeType = me.dockedItems.items[1].query('[xtype="radiogroup"]')[0].lastValue,
- data = me.getGridSelected();
- if (data && data.length > 0) {
- me.setLoading(true);
- var params = JSON.stringify({ baseDTOs: data, makeType: makeType });
- console.log(params);
- saas.util.BaseUtil.request({
- url: '/api/make/makeBalance/turnMake',
- params: params,
- method: 'POST',
- async: false
- })
- .then(function (res) {
- if (res.success) {
- me.setLoading(false);
- me.selModel.deselectAll();
- saas.util.BaseUtil.showSuccessToast('转单成功');
- // var orderList=res.data;
- // if(orderList){
- // orderList.forEach(function(order) {
- // let intValue = order.id, codeValue = order.code, name = order.name,
- // opage = 'make-makebase-formpanel';
- // if(name == ''){
- // opage = 'osmake-osmake-formpanel'
- // }
- // saas.util.BaseUtil.openTab(opage, name + "(" + codeValue + ")", codeValue + intValue, {
- // initId: intValue
- // });
- // });
- // }
- }
- })
- .catch(function (res) {
- me.setLoading(false);
- saas.util.BaseUtil.showErrorToast(('操作失败: ') + res.message);
- });
- } else {
- saas.util.BaseUtil.showErrorToast('请勾选至少一条明细。');
- }
- },
- getGridSelected: function () {
- var me = this,
- items = me.selModel.getSelection(),
- data = new Array();
- Ext.each(items, function (item, index) {
- if (!Ext.isEmpty(item.data['prCode']) && item.data['thisQty'] > 0 && item.data['planBeginDate'] != null) {
- data.push({
- planBeginDate: Ext.isDate(item.data['planBeginDate']) ? item.data['planBeginDate'].getTime() : Ext.Date.parseDate(item.data['planBeginDate'],'Y-m-d H:i:s').getTime(),
- prCode: item.data['prCode'],
- prId: item.data['prId'],
- thisQty: item.data['thisQty']
- });
- }
- });
- return data;
- },
- onExport: function (me) {
- var grid = me.ownerCt.ownerCt;
- var cfg = {
- type: 'xlsx',
- title: '自制品供需平衡',
- fileName: '自制品供需平衡' + 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);
- },
- onFilter: function () {
- var grid = this,
- filterFields = grid.query('[isFilter=true]');
- var filters = [];
- Ext.each(filterFields, function (filterField) {
- if (filterField.getFilter && filterField.getFilter()) {
- let filter = filterField.getFilter();
- if (filter) {
- filters.push(filter);
- }
- }
- });
- grid.store.clearFilter();
- grid.store.addFilter(filters);
- }
- });
|