ttk-app-core
Version:
enterprise develop framework
74 lines (61 loc) • 2.33 kB
JavaScript
import React from 'react'
import { action as MetaAction, AppLoader } from 'edf-meta-engine'
import {Icon} from 'edf-component'
import config from './config'
import {Tree} from 'edf-component'
import { FormDecorator } from 'edf-component'
import extend from './extend'
import moment from 'moment'
class action {
constructor(option) {
this.metaAction = option.metaAction
this.extendAction = option.extendAction
this.voucherAction = option.voucherAction
this.config = config.current
this.webapi = this.config.webapi
}
onInit = ({ component, injections }) => {
this.extendAction.gridAction.onInit({ component, injections })
this.component = component
this.injections = injections
if (this.component.props.setOkListener) {
this.component.props.setOkListener(this.onOk)
}
if (this.component.props.setCancelLister) {
this.component.props.setCancelLister(this.onCancel)
}
injections.reduce('init')
this.load()
}
load = async () => {
let enabledPeriod = this.component.props.enabledPeriod
if(enabledPeriod) this.injections.reduce('load', enabledPeriod)
}
disabledBeginDate = (current) => {
let endDate = this.metaAction.gf('data.other.enabledPeriod')
return current && current <= moment(endDate)
}
changeDate = (value) => {
this.injections.reduce('update', 'data.other.beginDate', value)
}
selectMethod = () => {
}
//确定
onOk = async () => {
let value = this.metaAction.gf('data.other.beginDate')
let res = await this.webapi.dateCard.createDate({paramValue: value})
}
// 关闭弹框和页面
onCancel = () => {
this.component.props.tabEdit('存货期初','remove')
}
}
export default function creator(option) {
const metaAction = new MetaAction(option),
extendAction = extend.actionCreator({ ...option, metaAction }),
voucherAction = FormDecorator.actionCreator({ ...option, metaAction }),
o = new action({ ...option, metaAction, extendAction,voucherAction }),
ret = { ...metaAction, ...extendAction.gridAction,...voucherAction, ...o }
metaAction.config({ metaHandlers: ret })
return ret
}