ttk-app-core
Version:
enterprise develop framework
255 lines (250 loc) • 6.6 kB
JavaScript
export function getMeta() {
return {
name: 'root',
component: 'Layout',
className: 'ttk-scm-home-state',
children: [{
name: 'top',
component: 'Layout',
// className: 'edfx-app-hot-search-widget-top',
children: [{
name: 'header',
component: 'Layout',
className: 'ttk-scm-home-state-header',
children: [{
name: 'left',
component: '::span',
children: '发票'
},
// {
// name: 'selectTime',
// component: '::div',
// className: 'edfx-app-home-voucher-header-left-select',
// children: {
// name: 'timeSelect',
// className: '',
// component: 'Select',
// showSearch: false,
// value: '{{data.period?data.period:data.periodList[0]}}',
// dropdownClassName: 'selectDate',
// onSelect: '{{function(v){$setField("data.period",v)}}}',
// children: {
// name: 'option',
// component: 'Select.Option',
// children: '{{data.periodList && data.periodList[_rowIndex]}}',
// key: '{{data.periodList && data.periodList[_rowIndex]}}',
// _power: 'for in data.periodList'
// }
// }
// },
{
name: 'right',
component: '::div',
className:'ttk-scm-home-state-header-right',
children: {
name:'btn',
component:'Radio.Group',
onChange:`{{function(v){$fieldChange('data.form.value',v.target.value)}}}`,
// defaultValue:'0',
children: [
{
name:'button1',
component: 'Radio.Button',
className: '{{data.type == "chart"?"focusIcon":"unfocusIcon"}}',
value:'0',
children:{
name: 'baobiao',
component: 'Icon',
fontFamily: 'edficon',
type: 'baobiao',
title: '图表',
key:'chart',
onClick:'{{$getChart}}'
},
},{
name:'button2',
component: 'Radio.Button',
className: '{{data.type == "table"?"focusIcon":"unfocusIcon"}}',
value:'1',
children:{
name: 'table',
component: 'Icon',
fontFamily: 'edficon',
type: 'biaoge',
title: '列表',
key:'table',
onClick:'{{$getTable}}'
},
},
{
name: 'refresh',
component: 'Icon',
fontFamily: 'edficon',
className: 'refresh homeIcon',
type: 'shuaxin',
title: '刷新',
onClick: '{{$refresh}}'
},
{
name: '展开',
component: 'Icon',
fontFamily: 'edficon',
className: 'unfold homeIcon',
type: '{{data.fold ? "shouhui" : "zhankai"}}',
title: '{{data.fold ? "收回" : "展开"}}',
onClick: '{{function(){$fold("business")}}}'
},
]
}
}
]
},{
name: 'tabNav',
component: 'Tabs',
// _visible: '{{data.other.isTab}}',
// activeKey: '{{data.form.activeKey}}',
// onChange: '{{function(v){$changeTab(v)}}}',
children: [{
name: "option",
component: 'Tabs.TabPane',
tab: [{
name: 'tab',
component: '::div',
children: "{{ data.other.businessArr && data.other.businessArr[_rowIndex].name }}",
}],
key: "{{ data.other.businessArr && data.other.businessArr[_rowIndex].id }}",
_power: 'for in data.other.businessArr'
}]
},{
name: 'spin',
component: 'Spin',
tip: '数据加载中...',
spinning: '{{data.loading}}',
children: [{
name: 'text',
component: '::div',
className: 'ttk-scm-home-state-text',
_visible: '{{data.form.textDisplay}}',
children: [{
name: 'span',
component: '::span',
className: 'ttk-scm-home-state-span',
children: [
'预估增值税税负率:', {
name: 'code',
component: '::span',
className: 'code',
children: "{{data.form.estimatedNegativeRate}}",
},
]
},
{
name: 'span',
component: '::span',
className: 'ttk-scm-home-state-span',
children: [
'预估应交增值税:', {
name: 'code',
component: '::span',
className: 'code',
children: "{{data.form.estimatedStressAddTax}}",
}, '元',
]
},
{
name: 'span',
component: '::span',
className: 'ttk-scm-home-state-span',
children: [
'税额:', {
name: 'code',
component: '::span',
className: 'code',
children: "{{data.form.taxTotal}}",
}, '元'
]
},
]
},{
name: 'center',
component: '::div',
className: 'ttk-scm-home-state-center',
children: [
{
name:'content',
component: '::div',
className: 'ttk-scm-home-state-content',
key: '{{data.mathRandom}}',
children: '{{$getContent()}}'
},{
name: 'bottom',
component: '::span',
className: 'ttk-scm-home-state-bottom',
_visible: '{{data.form.textDisplay}}',
children: [
'价税合计:', {
name: 'bottom',
component: '::span',
className: 'bottom',
children: "{{data.form.taxInclusiveAmountTotal}}",
}, '元'
]
}
]
}]
}]
}]
}
}
export function getInitState() {
return {
data: {
fold: "",
loading: false,
mathRandom: 0,
type:'chart',
form:{
value: '0',
invoiceSum : 10,
taxTotal : 10,
taxInclusiveAmountTotal : 10,
estimatedNegativeRate : 10,
estimatedStressAddTax : 10,
},
keys: [],
other: {
mathRandom: Math.random(),
action: 'out',
emptyData: true,
businessArr: [
{
"id": 2001001, "code": "2001001", "name": "销项发票"
},
{
"id": 3001002, "code": "3001002", "name": "进项发票"
},
],
}
}
}
}
export function addThousandsPosition(input, isFixed) {
// if (isNaN(input)) return null
if (isNaN(input)) return ''
let num
if (isFixed) {
num = parseFloat(input).toFixed(2)
} else {
num = input.toString()
}
let regex = /(\d{1,3})(?=(\d{3})+(?:\.))/g
return num.replace(regex, "$1,")
}
export function clearThousandsPosition(num) {
if (num && num.toString().indexOf(',') > -1) {
let x = num.toString().split(',')
return parseFloat(x.join(""))
} else {
return num
}
}