UNPKG

ttk-app-core

Version:
133 lines (122 loc) 4.11 kB
import React from 'react' import {action as MetaAction, AppLoader} from 'edf-meta-engine' import {Menu, Checkbox, DataGrid, Icon} from 'edf-component' import utils from 'edf-utils'; import extend from './extend' import config from './config' 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') this.load() } load = async (page, option) => { if (!page) { const form = this.metaAction.gf('data.pagination').toJS() page = {currentPage: form.current, pageSize: form.pageSize} } this.metaAction.sf('data.other.loading', true) // let appName = await this.webapi.user.queryApp(option) let appName = [{id:100,name:"财税云"}] this.getData(page).then((res) => { res.appName = appName this.injections.reduce('load', res) this.metaAction.sf('data.other.loading', false) }) } heightCount = () => { let name = '' if (this.component.props.modelStatus && (this.component.props.modelStatus == 1 || this.component.props.modelStatus == 2)) { name = "ttk-omp-app-list-user-contentHeight" } return name } getListRowsCount = () => { return this.metaAction.gf('data.list').size } selectRow = (rowIndex) => (e) => { this.injections.reduce('selectRow', rowIndex, e.target.checked) } //分页修改 pageChanged = (currentPage, pageSize) => { if (pageSize == null || pageSize == undefined) { pageSize = this.metaAction.gf('data.pagination').toJS().pageSize } let page = {currentPage, pageSize} const data = this.metaAction.gf('data.searchValue').toJS() this.metaAction.sf('data.other.loading', true) this.getData(page, data).then((res) => { this.injections.reduce('load', res) this.metaAction.sf('data.other.loading', false) }) } //获取列表内容 getData = async (pageInfo, searchValue) => { let response, pagination = this.metaAction.gf('data.pagination'), page = { pageSize: pagination.toJS().pageSize } if (pageInfo && pageInfo['currentPage']) { page.currentPage = pageInfo.currentPage page.pageSize = pageInfo.pageSize } for (var attr in searchValue){ if(!searchValue[attr]){ delete searchValue[attr] } } response = await this.webapi.user.query({page, ...searchValue}) return response } search = () => { const data = this.metaAction.gf('data.searchValue').toJS() // console.log('鼠标', data) this.metaAction.sf('data.other.loading', true) this.getData({pageSize: 50, currentPage: 1}, data).then((res) => { this.injections.reduce('load', res) this.metaAction.sf('data.other.loading', false) }) } dateSelect = (value) => { if(value != null){ let selectNode = document.getElementsByClassName('selectDate') selectNode && selectNode[1] && selectNode[1].firstChild.firstChild.click() this.metaAction.sf('data.searchValue.beginDate', this.metaAction.momentToString(value, 'YYYY-MM-DD')); }else { this.metaAction.sf('data.searchValue.beginDate', ''); } } dateSelect2 = (value) => { if(value != null){ this.metaAction.sf('data.searchValue.endDate', this.metaAction.momentToString(value, 'YYYY-MM-DD')); }else { this.metaAction.sf('data.searchValue.endDate', ''); } } export = () => { const data = this.metaAction.gf('data.searchValue').toJS() for (var attr in data){ if(!data[attr]){ delete data[attr] } } this.webapi.user.export(data); } } 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 }