ttk-app-core
Version:
enterprise develop framework
711 lines (704 loc) • 34.5 kB
JavaScript
import { consts, common } from 'edf-constant'
import moment from 'moment'
import { fromJS } from 'immutable'
export function getMeta() {
return {
name: 'root',
component: 'Layout',
className: 'app-pu-arrival-card',
id: 'app-pu-arrival-card',
onMouseDown: '{{$mousedown}}',
children: [{
name: 'header',
component: 'Layout',
className: 'app-pu-arrival-card-header',
children: [{
name: 'left',
component: 'Layout',
className: 'app-pu-arrival-card-header-left',
children: [{
name: 'page',
component: 'Button.Group',
className: 'page-prev-next',
children: [{
name: 'prev',
component: 'Button',
icon: 'left',
title: '上一张',
disabled: '{{data.other.prevDisalbed}}',
onClick: '{{$prev}}'
}, {
name: 'next',
component: 'Button',
icon: 'right',
title: '下一张',
disabled: '{{data.other.nextDisalbed}}',
onClick: '{{$next}}'
}]
}, {
name: 'setting',
component: 'Icon',
className: 'btn setting',
fontFamily: 'edficon',
type: 'shezhi',
title: '设置',
onClick: '{{$setting}}'
},{
name: 'shortcut',
component: 'Popover',
placement: "bottom",
overlayClassName: 'app-pu-arrival-card-header-left-jianpan',
arrowPointAtCenter: true,
content: {
name: 'keys',
component: 'ShortKey'
},
title: null,
children: {
component: 'Icon',
className: 'app-pu-arrival-card-header-left-iconbutton',
fontFamily: 'edficon',
type: 'jianpan',
title: '快捷键',
}
}]
}, {
name: 'right',
component: 'Layout',
className: 'app-pu-arrival-card-header-right',
children: [{
name: 'add',
// component: 'Button',
// // type: 'showy',
// onClick: '{{$add}}',
// disabled: '{{data.other.pageStatus === data.consts.pageStatus.ADD}}',
// children: '新增'
component: 'Button',
onClick: '{{function(){$save(true)}}}',
className: 'app-pu-arrival-card-header-right-but',
disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}',
children: '保存并新增'
}, {
name: 'audit',
component: 'Button',
disabled: '{{data.other.pageStatus === data.consts.pageStatus.ADD}}',
onClick: '{{$audit}}',
_visible:'{{data.other.auditVisible}}',
children: '{{$getAuditBtnText()}}'
// children:'审核'
}, {
name: 'history',
component: 'Button',
onClick: '{{$history}}',
children: '历史单据'
}, {
name: 'more',
component: 'Dropdown',
overlay: {
name: 'menu',
component: 'Menu',
onClick: '{{$moreMenuClick}}',
children: [{
name: 'del',
component: 'Menu.Item',
key: 'del',
disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY || data.other.pageStatus === data.consts.pageStatus.ADD}}',
children: '删除'
},/* {
name: 'generateReturn',
component: 'Menu.Item',
key: 'generateReturn',
disabled: '{{data.other.pageStatus === data.consts.pageStatus.ADD}}',
children: '生成采购退货'
}, {
name: 'antiAudit',
component: 'Menu.Item',
key: 'antiAudit',
onClick: '{{$audit}}',
disabled: '{{data.other.pageStatus === data.consts.pageStatus.ADD}}',
children: '反审核'
},*/{
name: 'pay',
component: 'Menu.Item',
key: 'pay',
// disabled: '{{data.other.pageStatus === data.consts.pageStatus.ADD}}',
disabled: `{{data.other.pageStatus === data.consts.pageStatus.EDIT
|| data.other.pageStatus === data.consts.pageStatus.ADD
|| data.form.paymentAmount == data.form.taxInclusiveAmount
|| data.form.taxInclusiveAmount < 0
}}`,
children: '付款'
}]
},
children: {
name: 'internal',
component: 'Button',
children: ['更多', {
name: 'down',
component: 'Icon',
type: 'down'
}]
}
}]
}]
},{
name: 'content',
component: '::div',
className: 'app-pu-arrival-card-content',
children:[{
name: 'title',
component: 'Layout',
className: 'app-pu-arrival-card-title',
children: [{
name: 'left',
component: 'Layout',
className: 'app-pu-arrival-card-title-left',
children: [{
name: 'audited',
component: '::img',
className: 'app-pu-arrival-card-title-left-tag',
src: require('./img/audited.png'),
_visible: '{{data.form.status == data.consts.VOUCHERSTATUS_Approved}}'
},
// {
// name: 'settled',
// component: '::img',
// className: 'app-pu-arrival-card-title-left-tag',
// src: require('./img/settled.png'),
// _visible: '{{data.form.settleStatus == data.consts.SETTLESTATUS_settled}}'
// }
]
}, {
name: 'center',
component: '::div',
className: 'app-pu-arrival-card-title-center',
children: {
name: 'title',
component: '::h1',
style: { fontWeight: 'bold' },
children: '采购单'
}
}, {
name: 'right',
component: 'Layout',
className: 'app-pu-arrival-card-title-right',
children: ['单据编号:', {
name: 'code',
component: '::div',
className: 'code',
style: { marginRight: 10 },
children: "{{data.form.code || ''}}"
}, {
name: 'attachmentItem',
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: 'app-pu-arrival-card-form-header',
children:'{{$renderFormContent()}}'
},{
name: 'details',
component: 'DataGrid',
className: 'app-pu-arrival-card-form-details',
headerHeight: 35,
rowHeight: 35,
footerHeight: 35,
rowsCount: '{{data.form.details.length}}',
enableSequence: true,
startSequence: 1,
// enableSequenceAddDelrow: true,
enableSequenceAddDelrow: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY ? false : true}}',
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: 100,
_visible: '{{$getColumnVisible("inventoryCode")}}',
header: {
name: 'header',
className: 'ant-form-item-required',
component: 'DataGrid.Cell',
children: '存货编码'
},
cell: {
name: 'cell',
component: '{{$isFocus(_ctrlPath) ? "Select" : "DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath)}}',
showSearch: true,
value: '{{data.form.details[_rowIndex] && 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: '{{$filterOption}}',
onFocus: '{{function(){$getInventory({}, `data.other.inventory`)}}}',
// 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: 100,
header: {
name: 'header',
className: 'ant-form-item-required',
component: 'DataGrid.Cell',
children: '存货名称'
},
cell: {
name: 'cell',
component: '{{$isFocus(_ctrlPath) ? "Select" : "DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath)}}',
showSearch: true,
value: '{{data.form.details[_rowIndex] && 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(){$getInventory({}, `data.other.inventory`)}}}',
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',
flexGrow: 1,
width: 90,
_visible: '{{$getColumnVisible("specification")}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '规格型号'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
className: "{{$getCellClassName(_ctrlPath) + ' app-pu-arrival-card-cell-disabled'}}",
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].specification}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'unit',
component: 'DataGrid.Column',
columnKey: 'unit',
flexGrow: 1,
width: 80,
_visible: '{{$getColumnVisible("unit")}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '计量单位'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
className: "{{$getCellClassName(_ctrlPath) + ' app-pu-arrival-card-cell-disabled'}}",
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].unitName}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'quantity',
component: 'DataGrid.Column',
columnKey: 'quantity',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
className: 'ant-form-item-required',
children: '数量'
},
cell: {
name: 'cell',
component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath) + " app-pu-arrival-card-cell-right"}}',
value: '{{$quantityFormat(data.form.details[_rowIndex].quantity,2,$isFocus(_ctrlPath))}}',
onChange: '{{$calc("quantity", _rowIndex, data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
},
footer: {
name: 'footer',
component: 'DataGrid.Cell',
className: 'app-pu-arrival-card-list-cell-right',
children: '{{$sumColumn("quantity")}}'
}
}, {
name: 'price',
component: 'DataGrid.Column',
columnKey: 'price',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
className: 'ant-form-item-required',
children: '单价'
},
cell: {
name: 'cell',
component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath) + " app-pu-arrival-card-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',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
className: 'ant-form-item-required',
children: '金额'
},
cell: {
name: 'cell',
component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath) + " app-pu-arrival-card-cell app-pu-arrival-card-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: 'app-pu-arrival-card-list-cell-right',
// children: '{{$sumColumn("amount")}}'
// }
}, {
name: 'taxRate',
component: 'DataGrid.Column',
columnKey: 'taxRate',
flexGrow: 1,
width: 100,
_visible: '{{$getControlVisible(0)}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '税率'
},
cell: {
name: 'cell',
component: '{{$isFocus(_ctrlPath) ? "Select" : "DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath)}}',
showSearch: false,
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].taxRateName}}',
onChange: '{{$calc("taxRateName", _rowIndex, data.form.details[_rowIndex])}}',
children: {
name: 'option',
component: 'Select.Option',
value: '{{data.other.taxRate && data.other.taxRate[_lastIndex].id}}',
children: '{{data.other.taxRate && data.other.taxRate[_lastIndex].name}}',
_power: 'for in data.other.taxRate'
},
_excludeProps: '{{$isFocus(_ctrlPath)? ["onClick"] : ["children"]}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'tax',
component: 'DataGrid.Column',
columnKey: 'tax',
flexGrow: 1,
width: 100,
_visible: '{{$getControlVisible(0)}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '税额'
},
cell: {
name: 'cell',
component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath) + " app-pu-arrival-card-cell app-pu-arrival-card-cell-right"}}',
value: '{{$quantityFormat(data.form.details[_rowIndex].tax,2,$isFocus(_ctrlPath))}}',
onChange: '{{$calc("tax", _rowIndex, data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
},
footer: {
name: 'footer',
component: 'DataGrid.Cell',
className: 'app-pu-arrival-card-list-cell-right',
children: '{{$sumColumn("tax")}}'
}
}, {
name: 'taxInclusiveAmount',
component: 'DataGrid.Column',
columnKey: 'taxInclusiveAmount',
flexGrow: 1,
width: 100,
_visible: '{{$getControlVisible(0)}}',
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '价税合计'
},
cell: {
name: 'cell',
component: '{{$isFocus(_ctrlPath) ? "Input.Number" : "DataGrid.TextCell"}}',
className: '{{$getCellClassName(_ctrlPath) + " app-pu-arrival-card-cell app-pu-arrival-card-cell-right"}}',
value: '{{$quantityFormat(data.form.details[_rowIndex].taxInclusiveAmount,2,$isFocus(_ctrlPath))}}',
onChange: '{{$calc("taxInclusiveAmount", _rowIndex, data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
},
footer: {
name: 'footer',
component: 'DataGrid.Cell',
className: 'app-pu-arrival-card-list-cell-right',
children: '{{$sumColumn("taxInclusiveAmount")}}'
}
},{
name: 'propertyName',
component: 'DataGrid.Column',
columnKey: 'propertyName',
flexGrow: 1,
width: 130,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '存货及服务分类'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
className: "{{$getCellClassName(_ctrlPath) + ' app-pu-arrival-card-cell-disabled'}}",
value: '{{$renderPropertyName(data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
}
}]
}, {
name: 'formFooter',
component: 'Layout',
className: 'app-pu-arrival-card-form-footer',
children: [{
name: 'settlement',
component: 'Form',
className: 'app-pu-arrival-card-form-footer-settlement',
children: [{
name: 'leftFooter',
component: '::div',
className: 'app-pu-arrival-card-form-footer-settlement-leftFooter',
children:[{
name: 'authentication',
component: '::div',
_visible: '{{$getControlVisible(1)}}',
children: [{
name: 'checkbox',
component: 'Checkbox',
checked: '{{data.form.authenticated}}',
disabled: '{{$isShowAuthenticated() || $getDisable()}}',
children: '{{$rendeRauthentication()}}',
onChange:'{{$authenticationChange}}'
}]
},{
// name:'authenticationSelect',
// component: 'Form.Item',
// label: '认证月份',
// _visible: '{{$getControlVisible(1)}}',
// children:[{
// name:'select',
// component: 'Select',
// value: '{{$authMonthValue()}}',
// disabled: true,
// children:{
// name: 'option',
// component: 'Select.Option',
// value: "{{ data.other.authMonthList && data.other.authMonthList[_rowIndex]}}",
// children: '{{data.other.authMonthList && data.other.authMonthList[_rowIndex]}}',
// _power: 'for in data.other.authMonthList'
// }
// }]
name:'authenticationSelect',
component: 'Form.Item',
label: '认证月份',
_visible: '{{$getControlVisible(1)}}',
children:[{
name:'datePicker',
component: 'DatePicker',
placeholder: '',
mode: ['month', 'month'],
value: '{{$authMonthValue()}}',
format: "YYYY-MM",
disabled: true,
}]
},{
name: 'deductible',
component: '::div',
children:'{{$renderDeduction()}}'
}]
},{
name: 'payDiv',
component: '::div',
className: 'app-pu-arrival-card-form-footer-settlement-payDiv',
children: '{{$renderPayDiv()}}'
}]
},]
}, {
name: 'footer',
component: 'Layout',
className: 'app-pu-arrival-card-footer',
children: [{
name: 'left',
component: 'Layout',
className: 'app-pu-arrival-card-footer-left',
children: [{
name: 'creator',
component: 'Layout',
children: ['制单人:', '{{data.form.creatorName}}'],
style: { marginRight: 30 }
}, {
name: 'auditor',
component: 'Layout',
children: ['审核人:', '{{data.form.auditorName}}'],
}]
}, {
name: 'right',
component: 'Layout',
className: 'app-pu-arrival-card-footer-right',
children: [ {
name: 'saveAndNew',
component: 'Button',
className: 'app-pu-arrival-card-footer-right-but',
onClick: '{{function(){$save(true)}}}',
disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}',
children: '保存并新增'
}, {
name: 'save',
component: 'Button',
onClick: '{{function(){$save(false)}}}',
disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}',
children: '保存'
},{
name: 'cancel',
component: 'Button',
onClick: '{{$add}}',
disabled: '{{data.other.pageStatus === data.consts.pageStatus.READ_ONLY}}',
children: '放弃'
}]
}]
}]
}]
}
}
export function getInitState(option) {
return {
data: {
form: {
details: [
blankDetail,
blankDetail,
blankDetail,
blankDetail,
blankDetail,
// blankDetail
],
settles: [{
bankAccountId: '',
amount: '',
bankAccountName: ''
}]
},
total: {
},
other: {
pageStatus: common.commonConst.PAGE_STATUS.ADD,
// isSignAndRetreat: false,
signAndRetreat: [{
id: 4000100001,
name: "即征即退",
},{
id: 4000100002,
name: "一般项目",
}],
defaultLength: 5, //默认初始行数
detailHeight: '245px',
isDisableBank: false,
auditVisible: false
},
consts: {
VOUCHERSTATUS_Approved: consts.consts.VOUCHERSTATUS_Approved, //已审核
SETTLESTATUS_settled: consts.consts.SETTLESTATUS_settled, //已结清
pageStatus: common.commonConst.PAGE_STATUS,
},
}
}
}
export const blankDetail = {
// warehouseId: null,
inventoryId: null,
unitId: null,
quantity: null,
price: null,
// taxInclusivePrice: null,
taxRateId: null,
taxRate:null,
tax: null,
amount: null,
taxInclusiveAmount: null,
propertyName:null,
propertyDetailName: null
}
// export const MOVEROW_UP = 0 //向上移动行
// export const MOVEROW_DOWN = 1 //向下移动行