ttk-app-core
Version:
enterprise develop framework
346 lines (341 loc) • 14.1 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: 'ttk-scm-app-warehouse-beginning',
id: 'ttk-scm-app-warehouse-beginning',
onMouseDown: '{{$mousedown}}',
children: [{
name: 'header',
component: 'Layout',
className: 'ttk-scm-app-warehouse-beginning-header',
children: [{
name: 'right',
component: 'Form',
className: 'ttk-scm-app-warehouse-beginning-header-left',
children: [{
name: 'date',
component: '::span',
className: 'leftDate',
children: '启用月份'
},{
name: 'date',
component: 'DatePicker.MonthPicker',
disabled: true,
value: '{{$stringToMoment(data.other.beginDate)}}',
},{
name: 'inventoryProperty',
component: 'Select',
showSearch: false,
placeholder: '存货分类',
allowClear: true,
className:'ttk-scm-app-warehouse-beginning-selectL',
value: '{{data.form.inventoryProperty}}',
onChange: `{{function(v){$getBeginList(data.other.inventoryProperty.filter(function(o){return o.id == v})[0])}}}`,
children: {
name: 'option',
component: 'Select.Option',
value: "{{data.other.inventoryProperty && data.other.inventoryProperty[_rowIndex].id}}",
title: "{{data.other.inventoryProperty && data.other.inventoryProperty[_rowIndex].name}}",
children: '{{data.other.inventoryProperty && data.other.inventoryProperty[_rowIndex].name}}',
_power: 'for in data.other.inventoryProperty'
}
},{
name: 'inventoryName',
component: 'Input.Search',
showSearch: true,
placeholder: '名称/规格型号/编码',
value: '{{data.other.searchInput}}',
className:'ttk-scm-app-warehouse-beginning-selectR',
onChange: `{{function(v){$searchList(v.target.value)}}}`,
},{
name: 'refreshBtn',
component: 'Icon',
fontFamily: 'edficon',
type: 'shuaxin',
className: 'reload',
onClick: '{{$refresh}}'
}]
},{
name: 'right',
component: 'Layout',
className: 'ttk-scm-app-warehouse-beginning-header-right',
children: [{
name: 'add',
component: 'Button',
onClick: '{{$aaa}}',
children: '存货台账'
},{
name: 'add',
component: 'Button',
onClick: '{{$save}}',
className: 'ttk-scm-app-warehouse-beginning-header-right-but',
children: '保存'
},{
name: 'import',
component: 'Icon',
fontFamily: 'edficon',
className: 'btn import daoru',
type: 'daoru',
title: '导入',
onClick: '{{$imports}}',
style: {
fontSize: 28,
lineHeight: '28px'
},
}, {
name: 'print',
component: 'Icon',
fontFamily: 'edficon',
className: 'btn print dayin',
type: 'dayin',
onClick: '{{$print}}',
title: '打印',
style: {
fontSize: 28,
lineHeight: '30px'
},
}, {
name: 'export',
component: 'Icon',
fontFamily: 'edficon',
className: 'btn export daoru',
type: 'daochu',
title: '导出',
onClick: '{{$export}}',
style: {
fontSize: 28,
lineHeight: '28px'
},
}]
}]
},{
name: 'content',
component: 'Layout',
className: 'ttk-scm-app-warehouse-beginning-content',
children: {
name: 'details',
component: 'DataGrid',
loading: '{{data.loading}}',
className: 'ttk-scm-app-warehouse-beginning-form-details',
headerHeight: 35,
rowHeight: 35,
rowsCount: '{{data.form.details.length}}',
columns: [{
name: 'seq',
component: 'DataGrid.Column',
columnKey: 'seq',
width: 41,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '序号'
},
cell: {
name: 'cell',
component: "DataGrid.Cell",
value: "{{Number(_rowIndex) + 1}}",
_power: '({rowIndex})=>rowIndex',
}
},{
name: 'code',
component: 'DataGrid.Column',
columnKey: 'code',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '存货编码'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
className: 'cellLeft',
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].code}}',
title: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].code}}',
_power: '({rowIndex}) => rowIndex',
}
},{
name: 'name',
component: 'DataGrid.Column',
columnKey: 'name',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '存货名称'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
className: 'cellLeft',
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].name}}',
title: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].name}}',
_power: '({rowIndex}) => rowIndex',
}
},{
name: 'specification',
component: 'DataGrid.Column',
columnKey: 'specification',
flexGrow: 1,
width: 100,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '规格型号'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
className: 'cellLeft',
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].specification}}',
title: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].specification}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'unitName',
component: 'DataGrid.Column',
columnKey: 'unitName',
width: 90,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '计量单位'
},
cell: {
name: 'cell',
component: 'DataGrid.TextCell',
value: '{{data.form.details[_rowIndex] && data.form.details[_rowIndex].unitName}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'quantity',
component: 'DataGrid.Column',
columnKey: 'quantity',
width: 140,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '数量'
},
cell: {
name: 'cell',
component: "Input.Number" ,
className: '{{data.form.style[_rowIndex] && data.form.style[_rowIndex].quantityStyle ? "redBorder" : ""}}',
value: '{{$quantityFormat(data.form.details[_rowIndex].quantity,6,$isFocus(_ctrlPath))}}',
onChange: '{{$calc("quantity", _rowIndex, data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
}
}, {
name: 'price',
component: 'DataGrid.Column',
columnKey: 'price',
width: 140,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '单价'
},
cell: {
name: 'cell',
component: "Input.Number",
className: '{{data.form.style[_rowIndex] && data.form.style[_rowIndex].priceStyle ? "redBorder" : ""}}',
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: 140,
header: {
name: 'header',
component: 'DataGrid.Cell',
children: '金额'
},
cell: {
name: 'cell',
component: 'Input.Number',
className: '{{data.form.style[_rowIndex] && data.form.style[_rowIndex].amountStyle ? "redBorder" : ""}}',
value: '{{$quantityFormat(data.form.details[_rowIndex].amount,2,$isFocus(_ctrlPath))}}',
onChange: '{{$calc("amount", _rowIndex,data.form.details[_rowIndex])}}',
_power: '({rowIndex}) => rowIndex',
}
}
]}
}]
}
}
export function getInitState(option) {
return {
data: {
loading: false,
otherFormA:{
details:[ blankDetail ], // 原材料
style:[ blankStyle ]
},
otherFormB:{
details:[ blankDetail ], // 商品
style:[ blankStyle ]
},
otherFormC:{
details:[ blankDetail ], // 周转材料
style:[ blankStyle ]
},
otherFormD:{
details:[ blankDetail ], // 半成品
style:[ blankStyle ]
},
otherFormAll: {
details:[ blankDetail ], // 全部
style:[ blankStyle ]
},
form: {
details: [
blankDetail
],
style: [
blankStyle
]
},
total: {
},
other: {
beginDate: moment().format('YYYY-MM'),
detailHeight: '245px',
inventoryProperty: [{
id: 1,
name: '商品'
}],
change: false,
searchInput: '',
otherFormBChange: false,
otherFormAChange: false,
otherFormDChange: false,
otherFormCChange: false,
otherFormAllChange: false
},
}
}
}
export const blankDetail = {
code:null,
id:null,
name:null,
specification:null,
unitName:null,
quantity: null,
price: null,
amount: null,
}
export const blankStyle = {
quantityStyle: null,
priceStyle: null,
amountStyle: null
}