Ext.define('make.view.osmake.osMakeCheckIn.FormPanel', {
extend: 'saas.view.core.form.FormPanel',
xtype: ['osmake-osmakecheckin-formpanel', 'osmakecheckin-formpanel'],
controller: 'osmake-osmakecheckin-formpanel',
viewModel: 'osmake-osmakecheckin-formpanel',
viewName: 'osmake-osmakecheckin-formpanel',
caller: 'OsMakeIn',
//字段属性
_title: '外协验收单',
_idField: 'id',
_codeField: 'pi_inoutno',
_statusField: 'pi_status',
_statusCodeField: 'pi_statuscode',
_auditmanField: 'pi_auditman',
_auditdateField: 'pi_auditdate',
_relationColumn: 'pd_piid',
_readUrl: '/api/make/prodinout/read',
_saveUrl: '/api/make/prodinout/save',
_auditUrl: '/api/make/prodinout/audit',
_unAuditUrl: '/api/make/prodinout/unAudit',
_deleteUrl: '/api/make/prodinout/delete',
_turnOsMakeInBackUrl: '/api/make/prodinout/turnOsMakeInBack',
initId: 0,
initComponent: function () {
Ext.apply(this, {
toolBtns: [{
xtype: 'button',
text: '转验退',
hidden: true,
bind: {
hidden: '{turnHidden}'
},
handler: 'turnOsMakeInBack'
}],
defaultItems: [{
xtype: 'hidden',
name: 'id',
fieldLabel: 'id',
allowBlank: true,
columnWidth: 0
}, {
xtype: "hidden",
name: "pi_class",
fieldLabel: "单据类型",
readOnly: true,
allowBlank: true,
defaultValue: 'OSMAKEIN',
columnWidth: 0.25
}, {
xtype: "hidden",
name: "pi_vendid",
fieldLabel: "供应商ID",
allowBlank: true,
columnWidth: 0.0
}, {
xtype: 'hidden',
name: 'pi_vendcode',
fieldLabel: '供应商编号'
}, {
xtype: 'vendorDbfindTrigger',
name: 'pi_vendname',
fieldLabel: '外协厂商',
allowBlank: false,
columnWidth: 0.5,
setValue: function (value) {
var me = this,
bind, valueBind;
var form = me.ownerCt;
var pi_contact = form.down('[name=pi_contact]');
if (value && value != '') {
pi_contact.setDisabled(false);
} else {
pi_contact.setDisabled(true);
}
if (me.hasFocus) {
bind = me.getBind();
valueBind = bind && bind.value;
if (valueBind && valueBind.syncing) {
if ((Ext.isEmpty(value) && Ext.isEmpty(me.value)) || value === me.value) {
return me;
} else if (Ext.isArray(value) && Ext.isArray(me.value) && Ext.Array.equals(value, me.value)) {
return me;
}
}
} else {
me.lastSelectedRecords = null;
}
if (value != null) {
me.doSetValue(value);
} else {
me.suspendEvent('select');
me.valueCollection.beginUpdate();
me.pickerSelectionModel.deselectAll();
me.valueCollection.endUpdate();
me.resumeEvent('select');
}
return me;
}
},{
xtype: "remotecombo",
name: "pi_contact",
fieldLabel: "联系人",
hiddenBtn: true,
storeUrl: '/api/document/vendor/getContactCombo',
columnWidth: 0.25
},{
xtype: "textfield",
name: "pi_tel",
fieldLabel: "联系电话",
columnWidth: 0.25
}, {
xtype: 'hidden',
name: 'pi_paymentsid',
fieldLabel: '付款方式ID'
}, {
xtype: 'hidden',
name: 'pi_paymentscode',
fieldLabel: '付款方式编号'
},{
xtype: "remotecombo",
name: "pi_payments",
fieldLabel: "付款方式",
storeUrl:'/api/document/paymentspay/list/enable',
valueField:'pa_name',
displayField: 'pa_name',
allowBlank: false,
columnWidth: 0.25,
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=pi_paymentsid]'),
paymentscode = form.down('[name=pi_paymentscode]');
paymentsid.setValue(record.data['id']);
paymentscode.setValue(record.data['pa_code']);
}
}
}, {
xtype: 'currencyCombo',
name:'pi_currency',
fieldLabel: '币种',
allowBlank: false,
rateField:'pi_rate',
columnWidth: 0.25,
}, {
xtype: 'numberfield',
fieldLabel: '税率',
name:'pi_taxrate',
allowBlank: true,
defaultValue: saas.util.BaseUtil.getDefualtTaxRate()
}, {
name: "detailGridField",
xtype: "detailGridField",
storeModel: 'make.model.osmake.OsMakeCheckInDetail',
deleteDetailUrl: '/api/make/prodinout/deleteDetail',
relativeBinds:{
refFields:['pd_orderid'],
fields:['pd_prodcode','pr_detail']
},
detnoColumn: 'pd_pdno',
columns: [{
text: "id",
dataIndex: "id",
xtype: "numbercolumn",
hidden: true
},{
text: "工单id",
dataIndex: "pd_orderid",
xtype: "numbercolumn",
hidden: true
}, {
text: "订单id",
dataIndex: "pd_maid",
xtype: "numbercolumn",
hidden: true
}, {
text: "物料id",
dataIndex: "pd_prodid",
xtype: "numbercolumn",
hidden: true
},{
text: "外协单号",
dataIndex: "pd_ordercode",
width: 150.0,
editor: {
displayField: "display",
editable: true,
format: "",
hideTrigger: false,
maxLength: 100.0,
minValue: null,
positiveNum: false,
store: null,
valueField: "value",
xtype: "osMakeMainMultiDbfindTrigger"
}
}, {
text: "物料编号",
width: 150.0,
dataIndex: "pd_prodcode",
items: null,
allowBlank: false
}, {
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: "规格",
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;
}
}, {
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: "验收数量",
dataIndex: "pd_inqty",
xtype: 'numbercolumn',
width: 110.0,
allowBlank: false,
editor: {
xtype: "numberfield",
decimalPrecision: 6,
minValue: 0
},
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
summaryType: 'sum',
summaryRenderer: function(v, d, f, m) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
}
}, {
text: "仓库id",
dataIndex: "pd_whid",
xtype: "numbercolumn",
hidden: true
}, {
text: "仓库编号",
dataIndex: "pd_whcode",
hidden: true
}, {
text: "仓库",
dataIndex: "pd_whname",
width: 110.0,
allowBlank: false,
editor: {
displayField: "display",
editable: true,
format: "",
hideTrigger: false,
maxLength: 100.0,
minValue: null,
positiveNum: false,
queryMode: "local",
store: null,
valueField: "value",
xtype: "warehouseDbfindTrigger"
}
}, {
text: "不含税单价(元)",
xtype: 'numbercolumn',
dataIndex: "pd_netprice",
width: 120,
hidden: true
}, {
text: "含税单价(元)",
xtype: 'numbercolumn',
width: 120,
editor: {
xtype: "numberfield",
decimalPrecision: 8,
minValue: 0
},
dataIndex: "pd_orderprice",
width: 120.0,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 8, true);
},
listeners: {
edit: function (value, grid) {
let me=this;
var r = grid.getSelection()[0],
pd_taxrate = r.get('pd_taxrate');
if(value>0) {
let form = me.up('form');
let pi_taxrate = form.down('[name=pi_taxrate]');
if(pi_taxrate && pi_taxrate.value>0){
pd_taxrate=pi_taxrate.value;
r.set('pd_taxrate',pd_taxrate);
}
var v = value / (1 + pd_taxrate / 100);
r.set('pd_netprice', Number(saas.util.BaseUtil.numberFormat(v, 8, false)));
}else{
r.set('pd_netprice', 0);
}
if(r.modified && Object.assign(r.modified) && Object.keys(Object.assign(r.modified)).length==1 && Object.keys(Object.assign(r.modified))[0]=='pd_taxrate'){
r.dirty=false;
}
}
}
}, {
text: "税率(%)",
xtype: 'numbercolumn',
dataIndex: "pd_taxrate",
width: 120,
hidden: true
}, {
text: "不含税金额(元)",
xtype: 'numbercolumn',
dataIndex: "pd_nettotal",
width: 120,
hidden: true
}, {
text: "税额(元)",
xtype: 'numbercolumn',
dataIndex: "pd_taxamount",
hidden: true,
width: 120,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFixFormat(v, 2, true);
},
summaryType: 'sum',
summaryRenderer: function(v, d, f, m) {
return saas.util.BaseUtil.numberFixFormat(v, 2, true);
}
}, {
text: "价税合计(元)",
xtype: 'numbercolumn',
dataIndex: "pd_ordertotal",
width: 120,
hidden: true,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFixFormat(v, 2, true);
},
summaryType: 'sum',
summaryRenderer: function(v, d, f, m) {
return saas.util.BaseUtil.numberFixFormat(v, 2, true);
}
}, {
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: 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: "开票数量",
xtype: 'numbercolumn',
dataIndex: "pd_auditbillqty",
width: (saas.util.BaseUtil.getBillOutSource("BillOutARSource") == 'PRODIOAUTO')? 0.0:110.0,
ignore: true,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
},
summaryType: 'sum',
summaryRenderer: function(v, d, f, m) {
return saas.util.BaseUtil.numberFormat(v, 6, true);
}
}, {
text: "开票金额",
xtype: 'numbercolumn',
dataIndex: "pd_auditbillamount",
width: (saas.util.BaseUtil.getBillOutSource("BillOutARSource") == 'PRODIOAUTO')? 0.0:110.0,
ignore: true,
renderer: function(v, m, r) {
return saas.util.BaseUtil.numberFormat(v, 2, true);
},
summaryType: 'sum',
summaryRenderer: function(v, d, f, m) {
return saas.util.BaseUtil.numberFormat(v, 2, true);
}
}, {
text: "备注",
dataIndex: "pd_remark",
width: 250,
items: null,
editor: {
xtype: "textfield"
}
}, {
text: "对账状态",
dataIndex: "apcheckStatus",
width: 100.0,
hidden: true,
ignore: true,
}, {
text: 'model映射需要',
dataIndex: 'productDTO',
hidden: true,
}, {
dataIndex: "pd_text1",
text: "自定义字段1",
width: 100,
hidden: true,
initHidden: false,
editor: {
xtype: "textfield"
},
}, {
dataIndex: "pd_text2",
text: "自定义字段2",
width: 100,
hidden: true,
initHidden: false,
editor: {
xtype: "textfield"
},
}, {
dataIndex: "pd_text3",
text: "自定义字段3",
width: 100,
hidden: true,
initHidden: false,
editor: {
xtype: "textfield"
},
}, {
dataIndex: "pd_text4",
text: "自定义字段4",
width: 100,
hidden: true,
initHidden: false,
editor: {
xtype: "textfield"
},
}, {
dataIndex: "pd_text5",
text: "自定义字段5",
width: 100,
hidden: true,
initHidden: false,
editor: {
xtype: "textfield"
},
}]
}, {
xtype: "textfield",
name: "pi_remark",
fieldLabel: "备注",
columnWidth: 0.6
}, {
xtype: "displayfield",
name: "pi_nettotal",
fieldLabel: "不含税金额(元)",
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: "pi_date", fieldLabel: "单据日期", columnWidth: 0.6, defaultValue: new Date() }, { xtype: "displayfield", name: "pi_taxtotal", fieldLabel: "税额(元)", labelWidth:200, labelAlign : 'right', columnWidth: 0.4, thousandSeparator: ',', readOnly: true, 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: "createTime", fieldLabel: "录入日期", readOnly: true, defaultValue: new Date() }, { xtype: "textfield", name: "pi_auditman", fieldLabel: "审核人", columnWidth: 0.3, readOnly: true }, { xtype: "hidden", name: "pi_auditdate", fieldLabel: "审核日期", readOnly: true }, { xtype: "displayfield", name: "pi_total", fieldLabel: "价税合计(元)", labelWidth:200, labelAlign : 'right', columnWidth: 0.4, thousandSeparator: ',', renderer: function (v){ if(!v){ v=0; } return '
'+saas.util.BaseUtil.numberFixFormat(v, 2, true)+'' }, readOnly: true }, { xtype: "textfield", name: "pi_billamount", fieldLabel: "开票金额", columnWidth: 0.3, readOnly: true, hidden:(saas.util.BaseUtil.getBillOutSource("BillOutARSource") == 'PRODIOAUTO') }, { xtype: "textfield", name: "pi_billstatus", fieldLabel: "开票状态", columnWidth: 0.3, readOnly: true, hidden:(saas.util.BaseUtil.getBillOutSource("BillOutARSource") == 'PRODIOAUTO') }, { xtype: "textfield", name: "pi_billstatuscode", fieldLabel: "开票状态码", columnWidth: 0.25, readOnly: true, hidden:true }, { xtype: "textfield", name: "pi_text1", fieldLabel: "自定义字段1", hidden: true, initHidden: false }, { xtype: "textfield", name: "pi_text2", fieldLabel: "自定义字段2", hidden: true, initHidden: false }, { xtype: "textfield", name: "pi_text3", fieldLabel: "自定义字段3", hidden: true, initHidden: false }, { xtype: "textfield", name: "pi_text4", fieldLabel: "自定义字段4", hidden: true, initHidden: false }, { xtype: "textfield", name: "pi_text5", fieldLabel: "自定义字段5", hidden: true, initHidden: false }], }); this.callParent(arguments); }, // beforeAudit: function () { // var me = this, // viewModel = me.getViewModel(), // grid = me.down('detailGridField'), // data = grid.getTrueData(); // Ext.Array.each(data, function (item) { // if (item.pd_orderprice == 0) { // saas.util.BaseUtil.showErrorToast(item.pd_pdno + '行' + item.pd_prodcode + '物料单价为0'); // } // }); // return true; // } });