UNPKG

ttk-app-core

Version:
108 lines (86 loc) 3.35 kB
import React from 'react' import ReactDOM from 'react-dom' import config from './config' import moment from 'moment' import extend from './extend' import * as data from './data' import utils, { fetch } from 'edf-utils' import { action as MetaAction, AppLoader, } from 'edf-meta-engine' import { Popover, Button, Link, Checkbox } from 'antd' import { PrintOption, Modal, Icon, LoadingMask } from 'edf-component' import { Map, fromJS, List, is } from 'immutable' import { consts } from 'edf-consts' class action { constructor(option) { this.metaAction = option.metaAction this.extendAction = option.extendAction this.config = config.current this.webapi = this.config.webapi } onInit = ({ component, injections }) => { this.extendAction.gridAction.onInit({ component, injections }) this.component = component this.injections = injections injections.reduce('init') if (this.component.props.setOkListener) { this.component.props.setOkListener(this.onOk) } let initData = this.component.props.initData this.load(initData) } load = async (initData) => { LoadingMask.show() try { let param = { ...initData } let response = await this.webapi.cancelDeclare.queryUnpaid(param) if (response.sbqkmxGrid.sbqkmxGridlb == undefined) { this.metaAction.toast('warning', '没有需要作废的项目') } else { this.injections.reduce('load', response.sbqkmxGrid.sbqkmxGridlb) } } catch (e) { } LoadingMask.hide() } onOk = async () => { return await this.save() } save = async () => { let initData = this.component.props.initData, list = this.metaAction.gf('data.list'), reason = this.metaAction.gf('data.form.cancelReason') if (list.size == 0) { this.metaAction.toast('warning', '没有需要作废的项目') return false } if (!reason) { this.metaAction.toast('warning', '请填写作废原因') return false } initData.isReturnValue = true initData.reason = this.metaAction.gf('data.form.cancelReason') let res = await this.webapi.cancelDeclare.cancel(initData) if (res && res.result == false) { this.metaAction.toast('error', res.error.message) return false }else{ this.metaAction.toast('success', '申报作废成功') return true } } changeMaxInput = (e) => { let noteLength = e.target.value.length if(noteLength > 200){ e.target.value = e.target.value.substring(0,200) } this.injections.reduce('setCancelReason', e.target.value) } } export default function creator(option) { const metaAction = new MetaAction(option), extendAction = extend.actionCreator({ ...option, metaAction }), o = new action({ ...option, metaAction, extendAction }), ret = { ...metaAction, ...extendAction.gridAction, ...o } metaAction.config({ metaHandlers: ret }) return ret }