import { Button, Modal, message, Row, Col, Spin } from 'antd'; import isEmpty from 'lodash/isEmpty' import cloneDeep from 'lodash/cloneDeep' import forEach from 'lodash/forEach' import { WeaAlertPage, WeaTools, WeaTableEdit, WeaSearchGroup, WeaRightMenu, WeaFormItem, WeaTab, WeaTop } from 'ecCom' import { WeaSwitch, WeaForm } from 'comsMobx'; import { inject, observer } from 'mobx-react'; import * as mobx from 'mobx'; import { i18n } from '../../public/i18n'; import * as Api from '../../apis/hrmInfoExtend'; // 引入API接口文件 const toJS = mobx.toJS; import '../../style/common.less'; export default class HrmInfoExtend extends React.Component { constructor(props) { super(props); this.state = { id: props.location.query.hrmResourceID, isEditor: false, loading: false, form: new WeaForm(), conditions: [], buttons: {}, date: '' } } componentDidMount() { this.init(); } init = () => { this.setState({ isEditor: false }); this.getData(); } getData = () => { this.state.loading = true; let params = { viewAttr: this.isEditor ? 2 : 1, id: this.state.id, } Api.getResourceExtendForm(params).then((res) => { if (res.code === 200) { this.state.form.initFormFields(res.data.conditions); this.setState({ conditions: res.data.conditions, buttons: res.data.buttons, loading: false }) } else { message.warning(res.msg); } }, error => { message.warning(error.msg); }) } getTopButtons = () => { const { isEditor, buttons } = this.state; const save = ; const back = ; const edit = ; const btns = []; try { if (isEditor) { if (buttons.hasSave) { btns.push(save); btns.push(back); } } else { if (buttons.hasEdit) { btns.push(edit); } } } catch (e) { } return btns; } getSearchs = () => { let { form, conditions, isEditor } = this.state; const { isFormInit } = form; let group = []; let tipPosition = 'bottom'; window.e9HideFormFieldKeys = []; isFormInit && conditions.forEach((c, i) => { let items = []; c.items.forEach((field, j) => { if (c.hide || (!isEmpty(field.otherParams) && field.otherParams.hide)) { window.e9HideFormFieldKeys.push(field.domkey[0]); } else { items.push({ com: ( ), colSpan: 1 }); } }); group.push() }); return group; } editCard = () => { this.setState({ isEditor: true }) this.getData(); } //todo 更新操作暂不处理 saveEditCard = () => { const {loading,form} = this.state; this.state.form.validateForm().then(f => { if (f.isValid) { this.state.loading = true; let pDatas = this.form.getFormParams(); Api.editResource({ ...{ id: this.id }, ...pDatas, ...this.getTableEditParams() }).then(data => { if (data.code == 200) { message.success(i18n.message.saveSuccess()); this.init(); this.getData(); this.selectedRowKeys = []; } else { message.warning(data.message); } this.loading = false; }, error => { message.warning(error.message); this.loading = false; }) } else { f.showErrors(); this.setDate(new Date()); this.loading = false; } }) } backCard = () => { this.init(); } render() { const { loading } = this.state; return (
{ loading ?
: this.getSearchs() }
) } }