Ext.define('make.view.osmake.osMake.FormPanel', {
extend: 'saas.view.core.form.FormPanel',
xtype: ['osmake-osmake-formpanel', 'osmake-formpanel'],
controller: 'osmake-osmake-formpanel',
viewModel: 'osmake-osmake-formpanel',
viewName: 'osmake-osmake-formpanel',
caller: 'OsMake',
//字段属性
_title: '外协单',
_idField: 'id',
_codeField: 'ma_code',
_statusField: 'ma_status',
_statusCodeField: 'ma_statuscode',
_auditmanField: 'ma_auditman',
_auditdateField: 'ma_auditdate',
_relationColumn: 'mm_maid',
_readUrl: '/api/make/make/read',
_saveUrl: '/api/make/make/save',
_auditUrl: '/api/make/make/audit',
_unAuditUrl: '/api/make/make/unAudit',
_deleteUrl: '/api/make/make/delete',
_calMaterial:'/api/make/make/calMaterial',
_turnPick:'/api/make/make/turnPick',
_turnBack:'/api/make/make/turnBack',
_turnScrap:'/api/make/make/turnScrap',
_turnIn:'/api/make/make/turnIn',
_end:'/api/make/make/end',
_resEnd:'/api/make/make/resEnd',
initId: 0,
getToolBarItems: function() {
let me = this, items = [];
let codeHeaderItems = [{
xtype: 'tbtext',
bind: {
html: 'NO. ' +
'{base.codeEditable ? "" : ' + me._codeField + '}'
}
}, {
xtype: 'textfield',
name: me._codeField,
minHeight: 24,
maxHeight: 24,
width: 200,
cls: 'x-codeeditor',
hidden: true,
allowBlank: false,
regex: /^[^\s~`!!@#¥$%\^……&*(())\-——\-_=+【\[\]】{{}}\|、\\;;::‘\'“”\",,《<。.》>、\/\?\?]*$/,
regexText: '不允许输入特殊字符',
bind: {
value: '{' + me._codeField + '}',
hidden: '{!base.codeEditable}'
},
enableKeyEvents: true,
listeners: {
blur: 'codeEditorBlur',
keydown: function(th, e, eOpts) {
if(e.keyCode == 13) {
th.fireEvent('blur');
}
},
show: function (field, eOpts) {
field.focus();
}
}
}, {
xtype: 'tbtext',
cls: 'x-audited',
hidden: true,
bind: {
hidden: '{!(' + me._statusCodeField + ' == "AUDITED" || '+ me._statusCodeField + ' == "END" )}',
html: `{${me._statusCodeField}=="AUDITED" ? "已审核" : "已结案"}`
}
}, {
xtype: 'button',
cls: 'x-codeeditor-btn',
bind: {
iconCls: 'fa {base.codeEditable ? "fa-check-circle" : "fa-edit"}',
hidden: '{!base.editable || (' + me._statusCodeField + ' == "AUDITED" || '+ me._statusCodeField + ' == "END")}'
},
handler: 'codeEditorClick'
}, '->'];
if(me.codeInHeader) {
items = items.concat(codeHeaderItems);
}
items.push('->');
items = items.concat(me.toolBtns.map(function (btn) {
btn.cls = btn.cls ? btn.cls + ' x-formpanel-btn-blue' : 'x-formpanel-btn-blue';
return btn;
}).concat(me.defaultBtns))
return items;
},
/**
* 一些初始化viewModel的方法
*/
initViewModel: function () {
let me = this,
codeField = me._codeField,
statusField = me._statusField,
statusCodeField = me._statusCodeField,
viewModel = me.getViewModel(),
auditTexts = me.auditTexts;
viewModel.set(codeField, '');
viewModel.set('createTime', Ext.Date.format(new Date(), 'Y-m-d H:i:s'));
viewModel.set('updateTime', Ext.Date.format(new Date(), 'Y-m-d H:i:s'));
viewModel.set('creatorId', viewModel.get('account').id);
viewModel.set('creatorName', viewModel.get('account').realname);
if (statusCodeField) {
let o = {};
o['bindEditable'] = {
bind: '{' + statusCodeField + '}',
get: function(value) {
// viewModel.set(statusField, value == 'AUDITED' ? '已审核' : '未审核');
viewModel.set(statusField, value ? (value == auditTexts.auditCode ? auditTexts.auditText : auditTexts.unAuditText) : null);
// viewModel.set('auditBtnText', value == 'AUDITED' ? '反审核' : '审核');
viewModel.set('auditBtnText', value == auditTexts.auditCode ? auditTexts.unAuditBtnText : auditTexts.auditBtnText);
// me.setEditable(value != 'AUDITED');
// form.editable表示强制设置表单编辑属性,与状态无关
if (!Ext.isBoolean(me.editable)) {
me.setEditable(value != auditTexts.auditCode && value != me.submitConfig.submittedCode && value != 'END');
}
return value;
}
};
viewModel.setFormulas(o);
// viewModel.set(statusCodeField, "UNAUDITED");
viewModel.set(statusCodeField, auditTexts.unAuditCode);
} else {
// viewModel.set('auditBtnText', "审核");
viewModel.set('auditBtnText', auditTexts.auditBtnText);
}
},
initComponent: function () {
var me = this;
me.defaultBtns = [{
cls: 'x-formpanel-btn-blue',
xtype: 'button',
text: '新增',
hidden: true,
bind: {
hidden: '{!showAddBtn || !id}'
},
handler: 'add'
}, {
hidden: true,
xtype: 'button',
text: '复制',
handler: 'onCopy',
bind: {
hidden: '{!showCopyBtn || !'+ me._idField + '}',
}
}, {
hidden: true,
xtype: 'button',
text: '保存',
handler: 'onSave',
cls:'save-btn',
bind: {
hidden: '{!showSaveBtn || '+ me._statusCodeField + ' == "AUDITED" || '+ me._statusCodeField + ' == "END"}',
disabled: '{!base.valid || '+ me._statusCodeField + ' == "AUDITED" || '+ me._statusCodeField + ' == "END"}',
tooltip:'{formBlank}'
}
}, {
hidden: true,
xtype: 'button',
text: '删除',
bind: {
hidden: '{!showDeleteBtn || deleteHidden || ' + me._statusCodeField + ' == "AUDITED" || '+ me._statusCodeField + ' == "END" || '+me._statusCodeField+'=="' + me.submitConfig.submittedCode + '"}'
},
handler: 'delete'
}, {
hidden: true,
xtype: 'button',
bind: {
text: `{${me._statusCodeField}=="${me.submitConfig.submittedCode}"?"${me.submitConfig.unSubmitBtnText}":"${me.submitConfig.submitBtnText}"}`,
disabled: '{!base.valid}',
hidden:`{!showSubmitBtn || !id || ${me._statusCodeField}=="AUDITED" || ${me._statusCodeField}=="END"}`
},
handler: "onSubmitBtnClick",
}, {
hidden: true,
xtype: 'button',
bind: {
text: '{auditBtnText}',
disabled: '{!base.valid}',
hidden:'{!showAuditBtn}'
},
handler: "auditBtnClick",
}];
Ext.apply(this, {
toolBtns: [{
xtype: 'button',
text: '用料计算',
hidden: true,
bind: {
hidden: '{ !(id && ma_statuscode =="UNAUDITED") }'
},
handler: 'calMaterial'
},{
text: '转领料',
xtype: 'button',
handler: 'turnPick',
bind:{
hidden: '{turnHidden}',
},
menu: {
cls:'x-query-menu',
anchor: '100%',
items:[{
text:'转退料',
handler:'turnBack'
},{
text:'转报废',
handler:'turnScrap'
}]
}
},{
xtype: 'button',
text: '转验收',
hidden: true,
bind: {
hidden: '{turnHidden}'
},
handler: 'turnIn'
},{
xtype: 'button',
text: '结案',
hidden: true,
bind: {
hidden: '{turnHidden}'
},
handler: 'end'
},{
xtype: 'button',
text: '反结案',
hidden: true,
bind: {
hidden: '{!(ma_statuscode=="END")}'
},
handler: 'resEnd'
},{
xtype: 'button',
text: '用料修改',
hidden: true,
bind: {
hidden: '{turnHidden}'
},
handler: 'modifyMaterial'
},{
xtype: 'button',
text: '更新外协信息',
hidden: true,
bind: {
hidden: '{turnHidden}'
},
handler: 'modifyVendInfo'
},{
xtype: 'button',
text: '工单变更',
hidden: true,
bind: {
hidden: '{turnHidden}'
},
handler: 'modifyMake'
}],
defaultItems: [{
xtype: 'hidden',
name: 'id',
fieldLabel: 'id',
allowBlank: true,
columnWidth: 0
},{
xtype: 'productMDbfindTrigger',
name: 'ma_prodcode',
fieldLabel: '产品编号',
allowBlank: false,
},{
xtype: 'textfield',
name: "pr_detail",
fieldLabel: "产品名称",
readOnly: "true",
ignore: true
},{
xtype: 'textfield',
name: "pr_spec",
fieldLabel: "产品规格",
readOnly: "true",
maxLength: 200,
hidden: true,
ignore: true
},{
xtype: 'tipTextfield',
name: "pr_orispeccode",
fieldLabel: "产品型号",
editable: false,
ignore: true,
bind:{
otherInfoTip:'厂家/品牌:{pr_brand}
产品规格:{pr_spec}'
}
},{
xtype: 'hidden',
name: "pr_brand",
fieldLabel: "厂家/品牌",
ignore: true,
},{
xtype: 'hidden',
name: "ma_prodid",
fieldLabel: "产品ID",
},{
xtype: "remotecombo",
name: "ma_kind",
fieldLabel: "外协类型",
storeUrl:'/api/make/kind/list/osmake',
valueField:'mk_name',
displayField: 'mk_name',
allowBlank: false,
columnWidth: 0.25,
addHandler: function (b) {
var form = this.ownerCmp.ownerCt;
this.dialog = form.add({
xtype: 'make-makekind-window',
bind: {
title: '新增外协类型'
},
dataKind: 'makekind',
_parent: form,
_combo: this.ownerCmp,
record: null,
session: true,
viewModel: {
data: {
theKind: {
id:0,
mk_name: null,
mk_makind: 'OSMAKE',
mk_allowover: null,
mk_unsetfinish:null,
mk_zeroprice:null,
mk_autoend:null,
mk_reminddays:null,
mk_ifmrpkind:null,
mk_makind_h:true
},
zeropricehide:false,
}
}
});
this.dialog.show();
},
editHandler:function(btn,type){
saas.util.BaseUtil.openTab('make-makekind-makekindlist', '外协类型设置','maintab--make-makekind-makekindlist');
var combo = btn.ownerCt.up('remotecombo');
if(combo){
combo.collapse();
}
},
listeners:{
change:function(f, newValue, oldValue, eOpts){
var me=this;
let form = f.ownerCt
if(newValue !=''){
saas.util.BaseUtil.request({
url: '/api/make/kind/list/osmake',
method: 'GET'
}).then(function(res) {
if(res.success){
if(res.data){
var flag=false;
Ext.Array.each(res.data,function(d,index){
if(d.mk_name == newValue){
form.down('[name=ma_kindid]').setValue(d.id);
flag = true;
}
if(flag){
return false;
}
});
}
}
}).catch(function(res) {
saas.util.BaseUtil.showErrorToast('选择的制造类型有误: ' + res.message);
});
}
}
}
},{
xtype: 'hidden',
name: "ma_kindid",
fieldLabel: "外协类型ID",
},{
xtype: 'numberfield',
name: 'ma_qty',
fieldLabel: '数量',
allowBlank: false,
}, {
xtype: 'numberfield',
name: 'ma_madeqty',
fieldLabel: '已完工数',
readOnly:true,
thousandSeparator: ',',
renderer: function (v){
if(!v){
v=0;
}
return '
'+saas.util.BaseUtil.numberFixFormat(v, 6, true)+'' }, ignore:true, },{ xtype: 'datefield', name: 'ma_planbegindate', fieldLabel: '计划开工日期', allowBlank: false, labelWidth:110, labelAlign : 'right', format: 'Y-m-d', },{ xtype: 'datefield', name: 'ma_planenddate', fieldLabel: '计划完工日期', allowBlank: false, labelWidth:110, labelAlign : 'right', format: 'Y-m-d', },{ xtype: "saledetailDbfindTrigger", name: "ma_salecode", fieldLabel: "订单编号", columnWidth: 0.25, defaultCondition:"sa_statuscode='AUDITED' and pr_manutype IN('MAKE','OSMAKE')" },{ xtype: 'hidden', name: "ma_saleid", fieldLabel: "订单ID", },{ xtype: 'hidden', name: "ma_sfcode", fieldLabel: "备货编号", }, { xtype: "customerDbfindTrigger", name: "ma_custname", fieldLabel: "客户名称", hidden: true, },{ xtype: 'hidden', name: "ma_custcode", fieldLabel: "客户编号", hidden: true, },{ xtype: 'hidden', name: "ma_custid", fieldLabel: "客户ID", },{ xtype: "datefield", name: "ma_delivery", fieldLabel: "交货日期" },{ xtype: 'hidden', name: "ma_kindid", fieldLabel: "制造类型ID", },{ xtype: 'hidden', name:'ma_tasktype', fieldLabel: '单据类型', allowBlank: false, defaultValue:'OS' },{ xtype: 'remotecombo', storeUrl: '/api/document/workcenter/getCombo', name: "ma_wcname", fieldLabel: "工作中心", hidden: true, addHandler: function (b) { var form = this.ownerCmp.ownerCt; this.dialog = form.add({ xtype: 'document-workcenter-window', bind: { title: '新增工作中心' }, dataKind: 'workcenter', _parent: form, _combo: this.ownerCmp, record: null, session: true }); this.dialog.show(); }, editHandler:function(btn,type){ saas.util.BaseUtil.openTab('document-workcenter-datalist', '工作中心','maintab--document-workcenter-datalist'); var combo = btn.ownerCt.up('remotecombo'); if(combo){ combo.collapse(); } } }, { xtype: "hidden", name: "ma_vendid", fieldLabel: "外协厂商ID" }, { xtype: "hidden", name: "ma_vendcode", fieldLabel: "外协厂商编号" }, { xtype: "vendorDbfindTrigger", name: "ma_vendname", fieldLabel: "外协厂商", columnWidth:0.25, // allowBlank: false, }, { xtype: "textfield", name: "ma_contact", fieldLabel: "联系人", hidden: true, }, { name: "ma_shipaddresscode", xtype: "remotecombo", fieldLabel: "交货地址", editable: false, allowBlank: true, columnWidth: 0.25, storeUrl: '/api/document/address/getCombo', hiddenBtn: false, //true 则会关闭新增按钮功能 addHandler: function (b) { var form = this.ownerCmp.ownerCt; this.dialog = form.add({ xtype: 'document-address-window', bind: { title: '新增交货地址' }, _parent: form, _combo: this.ownerCmp, record: null, session: true }); this.dialog.show(); }, editHandler: function(btn){ saas.util.BaseUtil.openTab('document-address-datalist', '交货地址','maintab--other-address'); var combo = btn.ownerCt.up('remotecombo'); if(combo){ combo.collapse(); } } },{ xtype: "textfield", name: "ma_tel", fieldLabel: "联系电话", hidden: true, }, { xtype: 'hidden', name: 'ma_paymentscode', fieldLabel: '付款方式编号' }, { xtype: 'hidden', fieldLabel: '付款方式ID', name: "ma_paymentsid", },{ xtype: 'currencyCombo', name:'ma_currency', fieldLabel: '币种', // allowBlank: false, rateField:'ma_rate', },{ xtype: 'hidden', fieldLabel: '汇率', name:'ma_rate', allowBlank: false, },{ xtype: 'numberfield', fieldLabel: '税率', name:'ma_taxrate', allowBlank: true, defaultValue: saas.util.BaseUtil.getDefualtTaxRate() },{ xtype: "hidden", name: "ma_ipdid", fieldLabel: "取价ID" },{ xtype: 'numberfield', fieldLabel: '含税加工单价', name:'ma_taxprice', fixDecimal:false, decimalPrecision:8, thousandSeparator: ',', renderer: function (v){ if(!v){ v=0; } return '
'+saas.util.BaseUtil.numberFormat(v, 8, true)+''
}
},{
xtype: "remotecombo",
name: "ma_payments",
fieldLabel: "付款方式",
storeUrl:'/api/document/paymentspay/list/enable',
valueField:'pa_name',
displayField: 'pa_name',
// allowBlank: false,
addHandler: function (b) {
var document = Ext.create('saas.view.document.paymentspay.DataList', {});
var form = this.ownerCmp.ownerCt;
this.dialog = form.getController().getView().add({
xtype: 'document-paymentspay-window',
bind: {
title: '新增付款方式'
},
dataKind: 'paymentspay',
belong: document.etc['paymentspay'],
_parent: form,
_combo: this.ownerCmp,
record: null,
session: true
});
this.dialog.show();
},
editHandler:function(btn,type){
saas.util.BaseUtil.openTab('document-paymentspay-datalist', '付款方式设置','maintab--document-paymentspay-datalist');
var combo = btn.ownerCt.up('remotecombo');
if(combo){
combo.collapse();
}
},
listeners:{
select: function ( combo, record, eOpts ) {
let form = combo.ownerCt;
let paymentsid = form.down('[name=ma_paymentsid]'),
paymentscode = form.down('[name=ma_paymentscode]');
paymentsid.setValue(record.data['id']);
paymentscode.setValue(record.data['pa_code']);
}
}
}, {
xtype: 'hidden',
name:'ma_tasktype',
fieldLabel: '单据类型',
allowBlank: false,
defaultValue:'OS'
},{
name: "detailGridField",
xtype: "detailGridField",
storeModel: 'make.model.make.MakeMaterial',
deleteDetailUrl: '/api/make/make/deleteDetail',
allowEmpty: true,
detnoColumn: 'mm_detno',
columns: [{
text: "id",
dataIndex: "id",
xtype: "numbercolumn",
hidden: true
}, {
text: "物料id",
dataIndex: "mm_prodid",
xtype: "numbercolumn",
hidden: true
},{
text: "物料编号",
width: 150,
dataIndex: "mm_prodcode",
items: null,
editor: {
displayField: "display",
editable: true,
format: "",
hideTrigger: false,
maxLength: 100,
minValue: null,
positiveNum: false,
queryMode: "local",
store: null,
valueField: "value",
xtype: "productMultiDbfindTrigger"
}
},{
text: "厂家/品牌",
hidden:true,
width: 100.0,
dataIndex: "pr_brand",
ignore: true,
renderer: function (v, m, r) {
if (!v) {
return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
}
return v;
}
},{
text: "物料名称",
width: 150.0,
dataIndex: "pr_detail",
ignore: true,
renderer: function (v, m, r) {
if (!v) {
return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
}
return v;
}
}, {
text: "型号",
width: 200.0,
dataIndex: "pr_orispeccode",
ignore: true,
renderer: function (v, m, r) {
var str = '';
if(r.data["productDTO"] ){
if(r.data["productDTO"]['pr_brand']){
str += '厂家/品牌:'+ r.data["productDTO"]['pr_brand'] + '
';
}
if(r.data["productDTO"]['pr_spec']){
str += '规格:' + r.data["productDTO"]['pr_spec'];
}
if(str) m.tdAttr = 'data-qtip="'+ str +'"';
if (!v) {
return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
}
}
return v;
}
}, {
text: "单位",
width: 65.0,
dataIndex: "pr_unit",
ignore: true,
renderer: function (v, m, r) {
if (!v) {
return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
}
return v;
}
},{
text: "数量小数位数",
hidden:true,
dataIndex: "pu_decimal",
ignore: true,
renderer: function (v, m, r) {
if (!v) {
return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
}
return v;
}
},{
text: "单位用量",
dataIndex: "mm_oneuseqty",
xtype: 'numbercolumn',
width: 110.0,
editor: {
xtype: "numberfield",
decimalPrecision: 6,
minValue: 0,
listeners:{
change:'onOneUseChange'
}
},
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
}
},{
text: "需求数",
dataIndex: "mm_qty",
xtype: 'numbercolumn',
width: 110,
editor: {
xtype: "numberfield",
decimalPrecision: 6,
minValue: 0
},
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
}
}, {
text: 'model映射需要',
dataIndex: 'productDTO',
hidden: true,
},{
text: "已领数",
xtype: 'numbercolumn',
dataIndex: "mm_havegetqty",
width: 110,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
ignore:true,
}, {
text: "已转领料数",
xtype: 'numbercolumn',
dataIndex: "mm_turngetqty",
width: 110,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
ignore:true,
}, {
text: "未领数",
xtype: 'numbercolumn',
dataIndex: "mm_restgetqty",
width: 110,
ignore: true,
renderer : function(v, m, r) {
v = r.get('mm_qty') + (r.get('mm_scrapqty')||0) - (r.get('mm_havegetqty')||0)-(r.get('mm_turngetqty')||0);
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
},{
text: "已转退料数",
xtype: 'numbercolumn',
dataIndex: "mm_turnbackqty",
width: 110,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
ignore:true,
},{
text: "制程不良数",
xtype: 'numbercolumn',
dataIndex: "mm_returnmqty",
width: 110,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
ignore:true,
}, {
text: "报废数",
xtype: 'numbercolumn',
dataIndex: "mm_scrapqty",
width: 110,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
ignore:true,
}, {
text: "已转报废数",
xtype: 'numbercolumn',
dataIndex: "mm_turnscrapqty",
width: 110,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
ignore:true,
}, {
text: "备注",
dataIndex: "mm_remark",
editor: {
xtype: "textfield"
},
width: 250,
},{
text: "规格",
hidden:true,
width: 200,
dataIndex: "pr_spec",
ignore: true,
renderer: function (v, m, r) {
if (!v) {
return r.data["productDTO"] ? r.data["productDTO"][m.column.dataIndex] : null;
}
return v;
}
}, ]
}, {
xtype: "textfield",
name: "ma_remark",
fieldLabel: "备注",
columnWidth: 0.6
},{
xtype: 'displayfield',
fieldLabel: '不含税金额(元)',
name:'ma_nettotal',
readOnly: true,
labelWidth:200,
labelAlign : 'right',
columnWidth: 0.4,
thousandSeparator: ',',
renderer: function (v){
if(!v){
v=0;
}
return '
'+saas.util.BaseUtil.numberFixFormat(v, 2, true)+'' }, }, { xtype: "datefield", name: "createTime", fieldLabel: "单据日期", readOnly: true, defaultValue: new Date(), columnWidth: 0.3, }, { xtype: "displayfield", name: "ma_getstatus", fieldLabel: "领料状态", columnWidth: 0.3, ignore:true, },{ xtype: 'displayfield', fieldLabel: '税额(元)', name:'ma_taxamount', readOnly: true, labelWidth:200, labelAlign : 'right', columnWidth: 0.4, thousandSeparator: ',', renderer: function (v){ if(!v){ v=0; } return '
'+saas.util.BaseUtil.numberFixFormat(v, 2, true)+'' }, },{ xtype: "hidden", name: "creatorId", fieldLabel: "录入人ID", readOnly: true }, { xtype: "textfield", name: "creatorName", fieldLabel: "录入人", readOnly: true, columnWidth: 0.3 }, { xtype: "hidden", name: "updaterId", fieldLabel: "更新人ID", readOnly: true }, { xtype: "hidden", name: "updaterName", fieldLabel: "更新人", readOnly: true }, { xtype: "hidden", name: "updateTime", fieldLabel: "更新日期", readOnly: true, defaultValue: new Date() }, { xtype: "textfield", name: "ma_auditman", fieldLabel: "审核人", columnWidth: 0.3, readOnly: true }, { xtype: "hidden", name: "ma_auditdate", fieldLabel: "审核日期", readOnly: true },{ xtype: 'displayfield', fieldLabel: '价税合计(元)', name:'ma_total', readOnly: true, labelWidth:200, labelAlign : 'right', columnWidth: 0.4, thousandSeparator: ',', renderer: function (v){ if(!v){ v=0; } return '
'+saas.util.BaseUtil.numberFixFormat(v, 2, true)+'' }, }], }); this.callParent(arguments); }, beforeAudit: function () { var me = this, controller = me.getController(), viewModel = me.getViewModel(), store = viewModel.get('detail0').detailStore, items = store.getData().items, controller = me.getController(), str = ''; //工单数量为0 if(!viewModel.get('ma_qty')){ saas.util.BaseUtil.showErrorToast("工单数量不允许为0"); return false; } var begin = Ext.isDate(viewModel.get("ma_planbegindate")) ? Ext.Date.format(viewModel.get("ma_planbegindate"), 'Y-m-d H:i:s') : viewModel.get("ma_planbegindate"); var end = Ext.isDate(viewModel.get("ma_planenddate")) ? Ext.Date.format(viewModel.get("ma_planenddate"), 'Y-m-d H:i:s') : viewModel.get("ma_planenddate"); //计划完工日期小于计划开工日期时限制保存并提示 if(begin > end ){ saas.util.BaseUtil.showErrorToast("计划完工日期不允许小于计划开工日期"); return false; } Ext.Array.each(items, function (item, i) { if (!item.get('mm_oneuseqty') && item.get('mm_prodcode')) { str = str + item.get('mm_detno') + ',' } }); if (str != '') { saas.util.BaseUtil.showConfirm('提示', '行: ' + str + '物料单位用量为0,是否继续审核?') .then(function (y) { if (y == 'yes') { controller.audit(); } }); } else { controller.audit(); } return false; }, beforeSave: function () { var me = this, controller = me.getController(), viewModel = me.getViewModel(), store = viewModel.get('detail0').detailStore, items = store.getData().items, controller = me.getController(), str = ''; //工单数量为0 if(!viewModel.get('ma_qty')){ saas.util.BaseUtil.showErrorToast("工单数量不允许为0"); return false; } var begin = Ext.isDate(viewModel.get("ma_planbegindate")) ? Ext.Date.format(viewModel.get("ma_planbegindate"), 'Y-m-d H:i:s') : viewModel.get("ma_planbegindate"); var end = Ext.isDate(viewModel.get("ma_planenddate")) ? Ext.Date.format(viewModel.get("ma_planenddate"), 'Y-m-d H:i:s') : viewModel.get("ma_planenddate"); //计划完工日期小于计划开工日期时限制保存并提示 if(begin > end ){ saas.util.BaseUtil.showErrorToast("计划完工日期不允许小于计划开工日期"); return false; } Ext.Array.each(items, function (item, i) { if (!item.get('mm_oneuseqty') && item.get('mm_prodcode')) { str = str + item.get('mm_detno') + ',' } }); if (str != '') { saas.util.BaseUtil.showConfirm('提示', '行: ' + str + '物料单位用量为0,是否继续保存?') .then(function (y) { if (y == 'yes') { controller.save(); } }); } else { controller.save(); } return false; }, setInquiry: function () { var form = this; var ma_kind = form.down('[name=ma_kind]'); if(!ma_kind.getValue()){ saas.util.BaseUtil.request({ url: '/api/make/kind/list/osmake', method: 'GET' }).then(function(res) { if(res.success){ if(res.data){ var flag=false; Ext.Array.each(res.data,function(d,index){ if(d.mk_ifmrpkind){ form.down('[name=ma_kind]').setValue(d.mk_name); flag = true; } if(flag){ return false; } }); } } }).catch(function(res) { saas.util.BaseUtil.showErrorToast(res.message); }); } //有预测来源无订单编号的工单 展示预测来源编号 var ma_salecode = form.down('[name=ma_salecode]'); var ma_sfcode = form.down('[name=ma_sfcode]'); if(!ma_salecode.getValue()&&ma_sfcode.getValue()){ ma_salecode.setValue(ma_sfcode.getValue()); } return true; } });