123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551 |
- Ext.define('make.view.make.makeBase.FormPanelController', {
- extend: 'saas.view.core.form.FormPanelController',
- alias: 'controller.make-makebase-formpanel',
- init: function (form) {
- var me = this;
- this.control({
- 'dbfindtrigger[name=ma_prodcode]':{
- beforerender:function(f){
- Ext.apply(f,{
- //放大镜赋值设置
- dbfinds:[{
- from:'id',to:'ma_prodid',ignore:true
- },{
- from:'pr_code',to:'ma_prodcode'
- },{
- from:'pr_detail',to:'pr_detail'
- },{
- from:'pr_spec',to:'pr_spec'
- },{
- from: 'pr_brand', to: 'pr_brand'
- },{
- from: 'pr_orispeccode', to: 'pr_orispeccode'
- },{
- from: 'pr_unit', to: 'pr_unit'
- }],
- });
- }
- },
- 'saledetailDbfindTrigger[name=ma_salecode]':{
- beforerender:function(f){
- Ext.apply(f,{
- //放大镜赋值设置
- dbfinds:[{
- from:'sa_id',to:'ma_saleid',ignore:true
- },{
- from:'sa_code',to:'ma_salecode'
- },{
- from:'sa_custname',to:'ma_custname'
- },{
- from:'sa_custid',to:'ma_custid'
- },{
- from: 'sa_custcode', to: 'ma_custcode'
- },{
- from: 'sd_delivery', to: 'ma_delivery'
- },{
- from: 'sd_prodcode', to: 'ma_prodcode'
- },{
- from: 'pr_detail', to: 'pr_detail'
- },{
- from: 'pr_spec', to: 'pr_spec'
- },{
- from: 'pr_orispeccode', to: 'pr_orispeccode'
- },{
- from:'sd_prodid',to:'ma_prodid'
- },{
- from: 'pr_brand', to: 'pr_brand'
- },],
- });
- }
- },
- //从表多选放大镜赋值关系 以及 tpl模板
- 'multidbfindtrigger[name=mm_prodcode]':{
- beforerender:function(f){
- Ext.apply(f,{
- //放大镜赋值设置
- dbfinds:[{
- from:'id',to:'mm_prodid',ignore:true
- },{
- from:'pr_code',to:'mm_prodcode'
- },{
- from:'pr_detail',to:'pr_detail'
- },{
- from:'pr_spec',to:'pr_spec'
- },{
- from: 'pr_brand', to: 'pr_brand'
- },{
- from: 'pr_orispeccode', to: 'pr_orispeccode'
- },{
- from: 'pr_unit', to: 'pr_unit'
- },{
- from: 'pu_decimal', to: 'pu_decimal'
- }],
- });
- }
- },
- 'multidbfindtrigger[name=pr_detail]': {
- beforerender: function (f) {
- Ext.apply(f, {
- dbfinds:[{
- from:'id',to:'mm_prodid',ignore:true
- },{
- from:'pr_code',to:'mm_prodcode'
- },{
- from:'pr_detail',to:'pr_detail'
- },{
- from:'pr_spec',to:'pr_spec'
- },{
- from: 'pr_brand', to: 'pr_brand'
- },{
- from: 'pr_orispeccode', to: 'pr_orispeccode'
- },{
- from: 'pr_unit', to: 'pr_unit'
- },{
- from: 'pu_decimal', to: 'pu_decimal'
- }],
- });
- }
- }
- });
- },
- /**
- * 单位用量改变改变,级联事件
- * @param {*} field
- */
- onOneUseChange: function (field) {
- if (field.value) {
- var me = this,
- view = me.getView(),
- vm = view.getViewModel(),
- oneuseqty = field.value || 0,
- ma_qty = vm.get('ma_qty') || 0,
- record = view.down('detailGridField').selModel.getLastSelected(),
- decimal = record.get('pu_decimal')||(record.get('productDTO')?record.get('productDTO')['pu_decimal']:0);
- if(ma_qty>0){
- qty = Number(Math.ceil(oneuseqty * ma_qty*Math.pow(10,decimal))/Math.pow(10,decimal));
- if(record.data['mm_qty'] != qty){
- record.set('mm_qty', qty);
- }
- }
- }
- },
- /**
- * 用料表计算
- */
- calMaterial: function(){
- var me = this,
- form = me.getView(),
- id = form.getForm().findField(form._idField);
- form.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._calMaterial + '/' + id.value,
- method: 'POST',
- })
- .then(function (localJson) {
- form.setLoading(false);
- if (localJson.success) {
- saas.util.BaseUtil.showSuccessToast('用料计算成功');
- saas.util.FormUtil.loadData(form);
- }
- })
- .catch(function (e) {
- form.setLoading(false);
- saas.util.BaseUtil.showErrorToast('用料计算失败: ' + e.message);
- });
- },
-
- /**
- * 生成领料单
- */
- turnPick: function(){
- var me = this,
- form = me.getView(),
- id = form.getForm().findField(form._idField);
- form.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._turnPick + '/' + id.value,
- method: 'POST',
- })
- .then(function (localJson) {
- form.setLoading(false);
- if (localJson.success) {
- var intValue = localJson.data.id,
- codeValue = localJson.data.code,
- name = '生产领料';
- saas.util.BaseUtil.openTab('make-makepick-formpanel', name + "(" + codeValue + ")", codeValue + intValue, {
- initId: intValue
- });
- saas.util.BaseUtil.showSuccessToast('转单成功');
- saas.util.FormUtil.loadData(form);
- }
- })
- .catch(function (e) {
- form.setLoading(false);
- saas.util.BaseUtil.showErrorToast('转单失败: ' + e.message);
- });
- },
- /**
- * 生成退料单
- */
- turnBack: function(){
- var me = this,
- form = me.getView(),
- id = form.getForm().findField(form._idField);
- form.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._turnBack + '/' + id.value,
- method: 'POST',
- })
- .then(function (localJson) {
- form.setLoading(false);
- if (localJson.success) {
- var intValue = localJson.data.id,
- codeValue = localJson.data.code,
- name = '生产退料';
- saas.util.BaseUtil.openTab('make-makereturn-formpanel', name + "(" + codeValue + ")", codeValue + intValue, {
- initId: intValue
- });
- saas.util.BaseUtil.showSuccessToast('转单成功');
- saas.util.FormUtil.loadData(form);
- }
- })
- .catch(function (e) {
- form.setLoading(false);
- saas.util.BaseUtil.showErrorToast('转单失败: ' + e.message);
- });
- },
- /**
- * 生成报废单
- */
- turnScrap: function(){
- var me = this,
- form = me.getView(),
- id = form.getForm().findField(form._idField);
- form.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._turnScrap + '/' + id.value,
- method: 'POST',
- })
- .then(function (localJson) {
- form.setLoading(false);
- if (localJson.success) {
- var intValue = localJson.data.id,
- codeValue = localJson.data.code,
- name = '生产报废';
- saas.util.BaseUtil.openTab('make-makescrap-formpanel', name + "(" + codeValue + ")", codeValue + intValue, {
- initId: intValue
- });
- saas.util.BaseUtil.showSuccessToast('转单成功');
- saas.util.FormUtil.loadData(form);
- }
- })
- .catch(function (e) {
- form.setLoading(false);
- saas.util.BaseUtil.showErrorToast('转单失败: ' + e.message);
- });
- },
- /**
- * 生成完工入库单
- */
- turnIn: function(){
- var me = this,
- form = me.getView(),
- id = form.getForm().findField(form._idField);
- form.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._turnIn + '/' + id.value,
- method: 'POST',
- })
- .then(function (localJson) {
- form.setLoading(false);
- if (localJson.success) {
- var intValue = localJson.data.id,
- codeValue = localJson.data.code,
- name ='完工入库';
- saas.util.BaseUtil.openTab('make-makein-formpanel', name + "(" + codeValue + ")", codeValue + intValue, {
- initId: intValue
- });
- saas.util.BaseUtil.showSuccessToast('转单成功');
- saas.util.FormUtil.loadData(form);
- }
- })
- .catch(function (e) {
- form.setLoading(false);
- saas.util.BaseUtil.showErrorToast('转单失败: ' + e.message);
- });
- },
- /**
- * 结案
- */
- end: function(){
- var me = this,
- form = me.getView(),
- id = form.getForm().findField(form._idField);
- form.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._end + '/' + id.value,
- method: 'POST',
- })
- .then(function (localJson) {
- form.setLoading(false);
- if (localJson.success) {
- if(localJson.data){
- //弹出结案检测的结果,弹出window
- me.showEndCheckDataWin(localJson.data);
- }else{
- saas.util.BaseUtil.showSuccessToast('结案成功');
- saas.util.FormUtil.loadData(form);
- }
- }
- })
- .catch(function (e) {
- form.setLoading(false);
- saas.util.BaseUtil.showErrorToast('结案失败: ' + e.message);
- });
- },
- /**
- * 反结案
- */
- resEnd: function(){
- var me = this,
- form = me.getView(),
- id = form.getForm().findField(form._idField);
- form.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._resEnd + '/' + id.value,
- method: 'POST',
- })
- .then(function (localJson) {
- form.setLoading(false);
- if (localJson.success) {
- saas.util.BaseUtil.showSuccessToast('反结案成功');
- saas.util.FormUtil.loadData(form);
- }
- })
- .catch(function (e) {
- form.setLoading(false);
- saas.util.BaseUtil.showErrorToast('反结案失败: ' + e.message);
- });
- },
- /**
- * 修改用料
- */
- modifyMaterial: function(button){
- //需要先选中行
- var me = this,
- form = me.getView(),
- grid = form.down('detailGridField'),
- record = grid.selModel.getLastSelected(),
- vm = form.getViewModel();
- if(null == record || record.get('mm_id')){
- saas.util.BaseUtil.showErrorToast('请先选择明细行');
- }else{
- me.materialDialog = form.add({
- xtype: 'make-makebase-modifymaterialwin',
- _parent:form,
- });
- me.materialDialog.getViewModel().set('form',{
- id:record.get('id'),
- mm_detno:record.get('mm_detno'),
- mm_prodid:record.get('mm_prodid'),
- mm_prodcode:record.get('mm_prodcode'),
- mm_oneuseqty:record.get('mm_oneuseqty'),
- mm_qty:record.get('mm_qty'),
- mm_remark:record.get('mm_remark'),
- pr_detail:record.get('pr_detail'),
- pr_spec:record.get('pr_spec'),
- pr_brand:record.get('pr_brand'),
- pr_orispeccode:record.get('pr_orispeccode'),
- pu_decimal: record.get('pu_decimal')||record.get('productDTO')['pu_decimal']});
- me.materialDialog.getViewModel().set('ma_qty',vm.get('ma_qty'));
- me.materialDialog.getViewModel().set('ma_id',vm.get('id'));
- me.materialDialog.show();
- }
- },
- /**
- * 工单变更
- */
- modifyMake: function(){
- var me = this,
- base = me.getView(),
- vm = base.getViewModel();
- var win = base.add(Ext.create('Ext.window.Window', {
- cls: 'x-window-dbfind',
- modal: true,
- minHeight: 150,
- width: 800,
- title: '工单变更',
- bodyPadding: 10,
- constrain: true,
- closable: true,
- layout: 'anchor',
- renderTo: base.getEl(),
- viewModel: {
- data: {
- make:{
- id:vm.get('id'),
- ma_code:vm.get('ma_code'),
- ma_prodcode:vm.get('ma_prodcode'),
- ma_qty:0,
- ma_turnmadeqty:vm.get('ma_turnmadeqty')
- },
- oldmake:{
- ma_oldqty:vm.get('ma_qty'),
- }
- }
- },
- items: [{
- xtype: 'form',
- layout: 'column',
- autoScroll: true,
- buttonAlign : 'center',
- _saveUrl:'/api/make/make/modifyMake',
- defaults:{
- columnWidth:0.33 ,
- margin: '0 0 10 0',
- labelAlign: 'right',
- labelWidth: 90,
- },
- bodyPadding: '8 12 8 12',
- items:[{
- xtype: 'hidden',
- fieldLabel: 'ID',
- allowBlank: false,
- bind:'{make.id}',
- },{
- xtype: 'textfield',
- name: 'ma_code',
- fieldLabel: '制造单号',
- allowBlank: false,
- readOnly: true,
- bind:'{make.ma_code}',
- },{
- xtype: 'textfield',
- name: 'ma_prodcode',
- fieldLabel: '产品编号',
- allowBlank: false,
- readOnly: true,
- bind:'{make.ma_prodcode}',
- },{
- xtype: 'textfield',
- name: 'ma_oldqty',
- fieldLabel: '原数量',
- readOnly: true,
- bind:'{oldmake.ma_oldqty}',
- },{
- xtype: 'numberfield',
- name: 'ma_qty',
- fieldLabel: '新数量',
- allowBlank: false,
- bind:'{make.ma_qty}',
- decimalPrecision: 6,
- },{
- xtype: 'numberfield',
- name: 'ma_turnmadeqty',
- fieldLabel: '已转完工数',
- readOnly: true,
- bind:'{make.ma_turnmadeqty}',
- }],
- buttons: [{
- text:'保存',
- disabled: true,
- formBind: true,
- handler:'onWinMSave'
- },{
- text: '关闭',
- handler:'onWinMClose'
- }]
- }],
- }));
- win.show();
- },
- //工单变更修改
- onWinMSave:function(btn){
- var me = this;
- view = btn.ownerCt.ownerCt.ownerCt,
- vm = view.getViewModel(),
- form = view.down('form'),
- params = Ext.clone(vm.get('make')),
- oldmake = Ext.clone(vm.get('oldmake'));
- if(Ext.isEmpty(params.ma_qty)){
- saas.util.BaseUtil.showErrorToast('新数量不能为空!');
- return false;
- }
- if(params.ma_qty<=0){
- saas.util.BaseUtil.showErrorToast('新数量不能小于等于0,如需关闭工单,请使用结案功能!');
- return false;
- }
- if(params.ma_qty == oldmake.ma_oldqty){
- saas.util.BaseUtil.showErrorToast('新数量等于旧数量无须变更!');
- return false;
- }
- view.setLoading(true);
- saas.util.BaseUtil.request({
- url: form._saveUrl,
- params: JSON.stringify(params),
- method: 'POST',
- })
- .then(function(localJson) {
- view.setLoading(false);
- if(localJson.success){
- saas.util.BaseUtil.showSuccessToast('修改成功');
- me.onWinMClose(btn);
- //刷新工单页面
- saas.util.FormUtil.loadData(me.getView());
- }
- })
- .catch(function(e) {
- view.setLoading(false);
- saas.util.BaseUtil.showErrorToast('修改失败: ' + e.message);
- });
- },
- onWinMClose:function(btn){
- btn.ownerCt.ownerCt.ownerCt.close();
- },
- /**
- * 显示结案检测结果弹框
- */
- showEndCheckDataWin: function(data){
- var me = this,
- base = me.getView(),
- vm = base.getViewModel();
- tab = saas.util.BaseUtil.getCurrentTab(),
- win = tab.add({
- xtype: 'make-makebase-endcheck-window',
- modal: true,
- onConfirm: function () {
- win.close();
- }
- });
- win.show();
- win.loadData(data);
- },
-
- });
|