ttk-app-core
Version:
enterprise develop framework
575 lines (571 loc) • 28.6 kB
JavaScript
import moment from 'moment'
export function getMeta() {
return {
name: 'root',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents',
id: 'ttk-scm-app-inventory-documents',
onMouseDown: '{{$mousedown}}',
children: [{
name: 'header',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents-header',
children: [{
name: 'left',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents-header-left',
children: [{
name: 'page',
component: 'Button.Group',
className: 'page-prev-next',
children: [{
name: 'prev',
component: 'Button',
icon: 'left',
title: '上一张',
onClick: '{{$prev}}'
}, {
name: 'next',
component: 'Button',
icon: 'right',
title: '下一张',
onClick: '{{$next}}'
}]
}, {
name: 'setting',
component: 'Icon',
className: 'btn setting',
fontFamily: 'edficon',
type: 'shezhi',
title: '设置',
onClick: '{{$setting}}'
}]
}, {
name: 'right',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents-header-right',
children: [{
name: 'shortcut',
component: 'Popover',
placement: "bottom",
overlayClassName: 'ttk-scm-app-inventory-documents-header-left-jianpan',
arrowPointAtCenter: true,
content: {
name: 'keys',
component: 'ShortKey'
},
title: null,
children: {
component: 'Icon',
className: 'ttk-scm-app-inventory-documents-header-left-iconbutton',
fontFamily: 'edficon',
type: 'jianpan',
title: '快捷键',
}
},{
name: 'saveAndNews',
component: 'Button',
_visible: '{{data.other.isSaved}}',
className: 'ttk-scm-app-inventory-documents-header-right-but',
onClick: '{{function(){$save(true)}}}',
children: '保存并新增'
},{
name: 'saves',
component: 'Button',
_visible: '{{data.other.isSaved}}',
className: 'ttk-scm-app-inventory-documents-header-right-but',
onClick: '{{function(){$save(false)}}}',
children: '保存'
}, {
name: 'saves',
component: 'Button',
_visible: '{{!data.other.isSaved}}',
onClick: '{{function(){$newAction()}}}',
className: 'ttk-scm-app-inventory-documents-header-right-but',
children: '新增'
},
{
name: 'history',
component: 'Button',
className: 'ttk-scm-app-inventory-documents-header-right-but',
onClick: '{{$history}}',
children: '历史单据'
},{
name: 'more',
component: 'Dropdown',
overlay: {
name: 'menu',
component: 'Menu',
onClick: '{{function(){$del(true)}}}',
children: [{
name: 'del',
component: 'Menu.Item',
key: 'del',
disabled: '{{data.other.isAdd}}',
children: '删除'
}]
},
children: {
name: 'internal',
component: 'Button',
children: ['更多', {
name: 'down',
component: 'Icon',
type: 'down'
}]
}
}]
}]
}, {
name: 'content',
component: '::div',
className: 'ttk-scm-app-inventory-documents-content',
children: [{
name: 'title',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents-title',
children: [{
name: 'left',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents-title-left',
children: ''
}, {
name: 'center',
component: '::div',
className: 'ttk-scm-app-inventory-documents-title-center',
children: {
name: 'title',
component: '::h1',
children: '{{data.other.typeName}}'
}
}, {
name: 'right',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents-title-right',
children: [{
name: 'codeA',
component: '::span',
children: '单据编号:',
_visible: "{{!!data.form.sourceVoucherCode}}"
}, {
name: 'code',
component: '::div',
className: 'code',
children: "{{data.form.sourceVoucherCode || ''}}"
}, {
name: 'attachment',
component: 'Attachment',
status: '{{data.form.attachmentStatus}}',
data: '{{data.form.attachmentFiles}}',
onDownload: '{{$download}}',
loading: '{{data.form.attachmentLoading}}',
visible: '{{data.form.attachmentVisible}}',
onDel: '{{$delFile}}',
uploadProps: {
action: '/v1/edf/file/upload', //上传地址,
headers: '{{$getAccessToken()}}',
accept: '', //接受的上传类型
data: {
"fileClassification": "ATTACHMENT"
},
onChange: '{{$attachmentChange}}',
beforeUpload: '{{$beforeUpload}}'
}
}]
}]
}, {
name: 'formHeader',
component: 'Form',
className: 'ttk-scm-app-inventory-documents-form-header',
children: '{{$renderFormContent()}}'
},{
name: 'formHeaders',
component: 'Form',
className: 'ttk-scm-app-inventory-documents-product',
_visible: '{{$renderProduct()}}',
children: [{
name: 'span',
component: '::span',
className: 'productSpan',
children: '成本核算'
}, {
name: 'helpPopover',
component: 'Popover',
content: '生产成本由直接材料、直接人工和制造费用三部分组成。直接材料是指在生产过程中的劳动对象,通过加工使之成为半成品或成品,它们的使用价值随之变成了另一种使用价值;直接人工是指生产过程中所耗费的人力资源,可用工资额和福利费等计算;制造费用则是指生产过程中使用的厂房、机器、车辆及设备等设施及机物料和辅料,它们的耗用一部分是通过折旧方式计入成本,另一部分是通过维修、定额费用、机物料耗用和辅料耗用等方式计入成本。',
placement: 'rightTop',
overlayClassName: 'ttk-scm-app-inventory-documents-helpPopover',
children: {
name: 'helpIcon',
component: 'Icon',
fontFamily: 'edficon',
type: 'bangzhutishi',
className: 'helpIcon'
}
}, {
name: 'materialCost',
component: 'Form.Item',
label: '直接材料',
children: [{
name: 'materialCost',
component: 'Input.Number',
value: '{{$quantityFormat(data.form.materialCost,2)}}',
onBlur: '{{function(v){$changeProNum("data.form.materialCost", v)}}}',
}]
}, {
name: 'laborCost',
component: 'Form.Item',
label: '直接人工(工资)',
children: [{
name: 'laborCost',
component: 'Input.Number',
value: '{{$quantityFormat(data.form.laborCost,2)}}',
onBlur: '{{function(v){$changeProNum("data.form.laborCost", v)}}}',
}]
}, {
name: 'manufacturCost',
component: 'Form.Item',
label: '制造费用',
children: [{
name: 'manufacturCost',
component: 'Input.Number',
value: '{{$quantityFormat(data.form.manufacturCost,2)}}',
onBlur: '{{function(v){$changeProNum("data.form.manufacturCost", v)}}}',
}]
}]
}, {
name: 'details',
component: 'DataGrid',
className: 'ttk-scm-app-inventory-documents-form-details',
headerHeight: 35,
rowHeight: 35,
footerHeight: 35,
rowsCount: '{{data.form.details.length}}',
enableSequence: true,
startSequence: 1,
enableSequenceAddDelrow: '{{!data.other.isAdd}}',
sequenceFooter: {
name: 'footer',
component: 'DataGrid.Cell',
children: '合计'
},
key: '{{data.other.detailHeight}}',
readonly: false,
style: '{{{return{height: data.other.detailHeight}}}}',
onAddrow: "{{$addRow('details')}}",
onDelrow: "{{$delRow('details')}}",
onKeyDown: '{{$gridKeydown}}',
scrollToColumn: '{{data.other.detailsScrollToColumn}}',
scrollToRow: '{{data.other.detailsScrollToRow}}',
columns: [
{
name: 'inventoryCode',
component: 'DataGrid.Column',
columnKey: 'inventoryCode',
// flexGrow: 1,
width: 150,
_visible: '{{$getGridVisible("inventoryCode")}}',
header: {
name: 'header',
className: 'ant-form-item-required',
component: 'DataGrid.Cell',
children: '{{$getGridName("inventoryCode")}}'
},
cell: {
name: 'cell',
component: '{{data.other.isAdd ? "DataGrid.TextCell" : ($isFocus(_ctrlPath)?"Select":"DataGrid.TextCell")}}',
className: '{{$getCellClassName(_ctrlPath)}}',
showSearch: true,
allowClear: true,
value: '{{ data.other.isAdd ? data.form.details[_rowIndex].inventoryCode : ($isFocus(_ctrlPath) ? data.form.details[_rowIndex] && data.form.details[_rowIndex].inventoryId : data.form.details[_rowIndex].inventoryCode)}}',
onChange: '{{$onFieldChange({ code: "data.form.details."+_rowIndex+".inventoryCode",' +
'id: "data.form.details."+_rowIndex+".inventoryId",' +
'name: "data.form.details."+_rowIndex+".inventoryName",' +
'unitId: "data.form.details."+_rowIndex+".unitId",' +
'unitName: "data.form.details."+_rowIndex+".unitName",' +
'propertyName: "data.form.details."+_rowIndex+".propertyName",' +
'propertyDetailName: "data.form.details."+_rowIndex+".propertyDetailName",' +
'taxRateName: "data.form.details."+_rowIndex+".taxRateName",' +
'specification: "data.form.details."+_rowIndex+".specification"}, "data.other.inventory",_rowIndex, data.form.details[_rowIndex])}}',
filterOption: '{{$filterOptionCode}}',
// onFocus: '{{function(){$getInventory({}, `data.other.inventory`)}}}',
onFocus: '{{function(){$getInventorys()}}}',
dropdownFooter:"{{$handleAddRecord('Inventory', 'inventory', _rowIndex, data.form.details[_rowIndex])}}",
children: {
name: 'option',
component: 'Select.Option',
value: '{{data.other.inventory && data.other.inventory[_lastIndex].id}}',
children: '{{data.other.inventory && data.other.inventory[_lastIndex].code}}',
_power: 'for in data.other.inventory'
},
_excludeProps: '{{$isFocus(_ctrlPath) ? ["onClick"] : ["children"]}}',
_power: '({rowIndex}) => rowIndex',
}
},
{
name: 'inventoryName',
component: 'DataGrid.Column',
columnKey: 'inventoryName',
flexGrow: 1,
width: 170,
_visible: '{{$getColumnVisible("inventoryName")}}',
header: {
name: 'header',
className: 'ant-form-item-required',
component: 'DataGrid.Cell',
children: '存货名称'
},
cell: {
name: 'cell',
// component: '{{$isFocus(_ctrlPath) ? "Select" : "DataGrid.TextCell"}}',
component: '{{data.other.isAdd ? "DataGrid.TextCell" : ($isFocus(_ctrlPath)?"Select":"DataGrid.TextCell")}}',
className: '{{$getCellClassName(_ctrlPath)}}',
showSearch: true,
allowClear: true,
value: '{{data.other.isAdd ? data.form.details[_rowIndex].inventoryName : ($isFocus(_ctrlPath) ? data.form.details[_rowIndex] && data.form.details[_rowIndex].inventoryId : data.form.details[_rowIndex].inventoryName)}}',
onChange: '{{$onFieldChange({ id: "data.form.details."+_rowIndex+".inventoryId",' +
'name: "data.form.details."+_rowIndex+".inventoryName",' +
'code: "data.form.details."+_rowIndex+".inventoryCode",' +
'unitId: "data.form.details."+_rowIndex+".unitId",' +
'unitName: "data.form.details."+_rowIndex+".unitName",' +
'propertyName: "data.form.details."+_rowIndex+".propertyName",' +
'propertyDetailName: "data.form.details."+_rowIndex+".propertyDetailName",' +
'taxRateName: "data.form.details."+_rowIndex+".taxRateName",' +
'specification: "data.form.details."+_rowIndex+".specification"}, "data.other.inventory", _rowIndex, data.form.details[_rowIndex])}}',
filterOption: '{{$filterOption}}',
onFocus: '{{function(){$getInventorys()}}}',
dropdownFooter: "{{$handleAddRecord('Inventory', 'inventory', _rowIndex, data.form.details[_rowIndex])}}",
children: {
name: 'option',
component: 'Select.Option',
value: '{{data.other.inventory && data.other.inventory[_lastIndex].id}}',
children: '{{data.other.inventory && data.other.inventory[_lastIndex].name}}',
_power: 'for in data.other.inventory'
},
_excludeProps: '{{$isFocus(_ctrlPath) ? ["onClick"] : ["children"]}}',
_power: '({rowIndex}) => rowIndex',
}
},
{
name: 'specification',
component: 'DataGrid.Column',
columnKey: 'specification',
width: 150,
_visible: '{{$getColumnVisible("specification")}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '规格型号'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
// component: '{{!data.other.isAdd ? "DataGrid.TextCell" : $isFocus(_ctrlPath)?"Select":"DataGrid.TextCell"}}',
className: "{{$getCellClassName(_ctrlPath) + ' ttk-scm-app-inventory-documents-cell-disabled'}}",
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].specification}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'unit',
component: 'DataGrid.Column',
columnKey: 'unit',
width: 150,
_visible: '{{$getColumnVisible("unitName")}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '计量单位'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
className: "{{$getCellClassName(_ctrlPath) + ' ttk-scm-app-inventory-documents-cell-disabled' + ' ttk-scm-app-inventory-documents-cell-center'}}",
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].unitName}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'quantity',
component: 'DataGrid.Column',
columnKey: 'quantity',
width: 130,
_visible: '{{$getColumnVisible("quantity")}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
className: 'ant-form-item-required',
children: '数量'
},
cell: {
name: 'cell',
// component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}',
component: '{{data.other.isAdd ? "DataGrid.TextCell" : $isFocus(_ctrlPath)?"Input.Number":"DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath) + " ttk-scm-app-inventory-documents-cell-right"}}',
value: '{{$quantityFormat(data.form.details[_rowIndex].quantity,6,$isFocus(_ctrlPath))}}',
onChange: '{{$calc("quantity", _rowIndex, data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
},
footer: {
name: 'footer',
component: 'DataGrid.Cell',
className: 'ttk-scm-app-inventory-documents-list-cell-right',
children: '{{$sumColumn("quantity")}}'
}
}, {
name: 'price',
component: 'DataGrid.Column',
columnKey: 'price',
width: 130,
_visible: '{{$getColumnVisible("price")}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
className: '{{$renderClass()}}',
children: '单价'
},
cell: {
name: 'cell',
component: '{{(data.other.isAdd && data.form.businessTypeId == 5001001001) ? "DataGrid.TextCell" : $isFocus(_ctrlPath)?"Input.Number":"DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath) + " ttk-scm-app-inventory-documents-cell-right"}}',
value: '{{$quantityFormat(data.form.details[_rowIndex].price,6,$isFocus(_ctrlPath))}}',
onChange: '{{$calc("price", _rowIndex,data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'amount',
component: 'DataGrid.Column',
columnKey: 'amount',
width: 130,
_visible: '{{$getColumnVisible("amount")}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
className: '{{$renderClass()}}',
children: '金额'
},
cell: {
name: 'cell',
component: '{{(data.other.isAdd && data.form.businessTypeId == 5001001001) ? "DataGrid.TextCell" : $isFocus(_ctrlPath)?"Input.Number":"DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath) + " ttk-scm-app-inventory-documents-cell ttk-scm-app-inventory-documents-cell-right"}}',
value: '{{$quantityFormat(data.form.details[_rowIndex].amount,2,$isFocus(_ctrlPath))}}',
onChange: '{{$calc("amount", _rowIndex,data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
},
footer: {
name: 'footer',
component: 'DataGrid.Cell',
className: 'ttk-scm-app-inventory-documents-list-cell-right',
children: '{{$sumColumn("amount")}}'
}
}]
}, {
name: 'footer',
component: '::div',
className: 'ttk-scm-app-inventory-documents-footer',
children: [{
name: 'left',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents-footer-left',
children: [{
name: 'creator',
component: 'Layout',
children: ['制单人:', '{{data.form.creatorName}}'],
}]
}, {
name: 'right',
component: 'Layout',
className: 'ttk-scm-app-inventory-documents-footer-right',
_visible: '{{data.other.isSaved}}',
children: [{
name: 'saveAndNew',
component: 'Button',
className: 'ttk-scm-app-inventory-documents-footer-right-but',
onClick: '{{function(){$save(true)}}}',
children: '保存并新增'
}, {
name: 'save',
component: 'Button',
onClick: '{{function(){$save(false)}}}',
children: '保存'
}, {
name: 'cancel',
component: 'Button',
// type: 'bluesky',
onClick: '{{$add}}',
children: '放弃'
}]
}]
}]
}]
}
}
export function getInitState(option) {
return {
data: {
form: {
isEnable: true,
sourceVoucherCode: undefined,
details: [
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail
],
businessTypeId: null,
materialCost: null,
laborCost: null,
manufacturCost: null,
// manufacturCost: [],
businessDate: moment().endOf('day'),
settles: [{
bankAccountId: '',
amount: '',
bankAccountName: ''
}]
},
total: {
},
other: {
defaultLength: 12, //默认初始行数
MOVEROW_UP: 0,
MOVEROW_DOWN: 1,
detailHeight: 8,
isDisableBank: false,
bussinessType: [],
enableDate: moment().format('YYYY-MM-DD'),
typeName: '库存单据',
docList: [],
isOk: true,
vouchered: false, // 是否生成凭证
isAdd: false, // 是否是新增的单据
isSaved: false //保存按钮是否显示
},
// consts: {
// VOUCHERSTATUS_Approved: consts.consts.VOUCHERSTATUS_Approved, //已审核
// SETTLESTATUS_settled: consts.consts.SETTLESTATUS_settled, //已结清
// pageStatus: common.commonConst.PAGE_STATUS,
// VATTAXPAYER_smallScaleTaxPayer:consts.consts.VATTAXPAYER_smallScaleTaxPayer,//小规模纳税人
// VATTAXPAYER_generalTaxPayer:consts.consts.VATTAXPAYER_generalTaxPayer //一般纳税人
// },
setting: {}
}
}
}
export const blankDetail = {
inventoryId: null,
unitId: null,
quantity: null,
price: null,
taxRateId: null,
tax: null,
amount: null,
taxInclusiveAmount: null,
propertyName: null,
propertyDetailName: null
}