ttk-app-core
Version:
enterprise develop framework
101 lines (88 loc) • 3.87 kB
JavaScript
import React from 'react'
import { DataGrid, Checkbox, Icon } from 'edf-component'
let centerArr = ['seq', 'disposeDate','disposeDateStr','assetReduceTypeName'],
rightArr = ['feeAmount','sellTax','origValue', 'accuDepreciation','sellTotal','sellTax', 'feeAmount']
export default function renderColumns(columns, list, _this){
let { Column, Cell } = DataGrid
let cols = [
<Column name='select' columnKey='select' width={34}
header={<Cell name='cb'>
<Checkbox checked={_this.extendAction.gridAction.isSelectAll("dataGrid")}
onChange={_this.extendAction.gridAction.selectAll("dataGrid")}>
</Checkbox>
</Cell>}
cell={(ps) => {
return <Cell name='cell'>
<Checkbox onChange={_this.selectRow(ps.rowIndex)} checked={list[ps.rowIndex].selected}></Checkbox>
</Cell>
}}
/>,
<Column name='operation' columnKey='operation' width={42}
fixedRight={true}
header={<Cell name='cb'>
<Icon type="youcezhankailanmushezhi" fontFamily='edficon' onClick = { function(data){_this.showTableSetting({value: true})} } />
</Cell>}
cell={(ps) => {
return (<Cell name='cell' className='app-oprate'>
<Icon type="chakan"
fontFamily='edficon'
disabled={list[ps.rowIndex].changeTypeId == 5100060004}
title="处置结果查看"
style={{fontSize: 23, cursor: 'pointer'}}
onClick={ function(){ _this.assetDisposeDetail(list[ps.rowIndex])} } />
</Cell>)
}}
/>
]
columns.forEach(op => {
if(op.isVisible){
let col = <Column name={op.id} columnKey={op.fieldName} isResizable={true} width={op.width}
header={<Cell name='header'>{op.caption}</Cell>}
cell={(ps) => {
return <Cell tip={op.fieldName!='docCode' ?true : false} className={getClassName(list[ps.rowIndex], op.fieldName)}>
{
op.fieldName=='docCode' ?
<p>{_this.getDocCodes(list[ps.rowIndex].docCodes, list[ps.rowIndex].docIds)}</p> :
(
(op.idFieldType == '1000040002' && Number(list[ps.rowIndex][op.fieldName])) ?
(addThousandsPosition(list[ps.rowIndex][op.fieldName])) :
list[ps.rowIndex][op.fieldName]
)
}
</Cell>
}}
/>
cols.push(col)
}
})
cols.push(<Column name='right' columnKey='right' flexGrow={1} width={0}
header={<Cell name='cb'></Cell>}
cell={(ps) => {
return <Cell name='cell' className={!Number(list[ps.rowIndex].seq) ? 'total':''}></Cell>
}}/>)
return cols
}
function getClassName(option, fieldName){
let leftName = 'mk-datagrid-cellContent-left',
rightName = 'mk-datagrid-cellContent-right'
if(centerArr.indexOf(fieldName)>-1){
return ''
}else if(rightArr.indexOf(fieldName)>-1){
return rightName
}else{
return leftName
}
}
function addThousandsPosition(value){
let num
if(value == 0){
return parseFloat(0).toFixed(2)
}
if (value != '') {
num = parseFloat(value).toFixed(2)
}else{
num = value.toString()
}
let regex = /(\d{1,3})(?=(\d{3})+(?:\.))/g
return num.replace(regex, "$1,")
}