/* * Author: 黎永顺 * name: 新增数据采集项 * Description: */ import React, { Component } from "react"; import { WeaBrowser, WeaFormItem, WeaInput, WeaSearchGroup } from "ecCom"; import { getSearchs } from "../../util"; import { Select } from "../ruleConfig"; import { PickDate } from "../appConfig"; import "./index.less"; class AddItems extends Component { constructor(props) { super(props); this.state = { baseInfo: { declareMonth: "", taxAgentId: "", taxAgentName: "", employeeId: "", employeeName: "", personArea: "ORGANIZATION", username: "", idcard: "" } }; } componentDidMount() { this.setState({ baseInfo: { ...this.state.baseInfo, declareMonth: this.props.editId.declareMonth || this.props.editId.taxYearMonth, taxAgentId: this.props.editId.taxAgentId, taxAgentName: this.props.editId.taxAgentName, employeeId: this.props.editId.employeeId, employeeName: this.props.editId.username } }); const fields = _.map(this.props.condition[0].items, it => { return it.domkey[0]; }); fields.map(item => { this.props.form.updateFields({ [item]: this.props.editId[item] || "" }); }); } componentWillReceiveProps(nextProps, nextContext) { if (nextProps.editId !== this.props.editId) { this.setState({ baseInfo: { ...this.state.baseInfo, declareMonth: nextProps.editId.declareMonth || nextProps.editId.taxYearMonth, taxAgentId: nextProps.editId.taxAgentId, taxAgentName: nextProps.editId.taxAgentName, employeeId: nextProps.editId.employeeId, employeeName: nextProps.editId.username } }); const fields = _.map(nextProps.condition[0].items, it => { return it.domkey[0]; }); fields.map(item => { nextProps.form.updateFields({ [item]: nextProps.editId[item] || "" }); }); } } render() { const { taxAgentOption = [], form, condition = [], isCum, isSpecial, editId } = this.props; const { baseInfo } = this.state; let items = [ { com: PickDate({ label: "税款所属期", viewAttr: _.isEmpty(editId) ? 3 : 1, labelCol: { span: 6 }, wrapperCol: { span: 18 }, format: "YYYY-MM", value: baseInfo.declareMonth, onChange: (data) => { this.setState({ baseInfo: { ...baseInfo, declareMonth: data.date } }); } }) }, { com: Select({ label: "个税扣缴义务人", viewAttr: _.isEmpty(editId) ? 3 : 1, options: taxAgentOption, value: baseInfo.taxAgentId, onChange: (data) => { this.setState({ baseInfo: { ...baseInfo, taxAgentId: data.selected, taxAgentName: data.showName } }); } }) }, { com: Browser({ label: "人员", viewAttr: _.isEmpty(editId) ? 3 : 1, value: baseInfo.employeeId, valueSpan: baseInfo.employeeName, onChange: ({ ids, names }) => { this.setState({ baseInfo: { ...baseInfo, employeeId: ids, employeeName: names } }); } }) } ]; const cumSituationitems = [ { com: PickDate({ label: "税款所属期", viewAttr: _.isEmpty(editId) ? 3 : 1, labelCol: { span: 6 }, wrapperCol: { span: 18 }, format: "YYYY-MM", value: baseInfo.declareMonth, onChange: (data) => { this.setState({ baseInfo: { ...baseInfo, declareMonth: data.date } }); } }) }, { com: Select({ label: "个税扣缴义务人", viewAttr: _.isEmpty(editId) ? 3 : 1, options: taxAgentOption, value: baseInfo.taxAgentId, onChange: (data) => { this.setState({ baseInfo: { ...baseInfo, taxAgentId: data.selected, taxAgentName: data.showName } }); } }) }, { com: Select({ label: "人员范围", viewAttr: _.isEmpty(editId) ? 3 : 1, options: [ { key: "ORGANIZATION", showname: "内部人员" } // { key: "EXT_EMPLOYEE", showname: "非系统人员" } ], value: baseInfo.personArea, onChange: (data) => { this.setState({ baseInfo: { ...baseInfo, personArea: data.selected } }); } }) } ]; const insider = [{ com: Browser({ label: "人员", viewAttr: _.isEmpty(editId) ? 3 : 1, value: baseInfo.employeeId, valueSpan: baseInfo.employeeName, onChange: ({ ids, names }) => { this.setState({ baseInfo: { ...baseInfo, employeeId: ids, employeeName: names } }); } }) }]; const noSysPerson = [ { com: InputCus({ label: "姓名", viewAttr: 2, onChange: (username) => { this.setState({ baseInfo: { ...baseInfo, username } }); } }) }, { com: InputCus({ label: "身份证号码", viewAttr: 3, onChange: (idcard) => { this.setState({ baseInfo: { ...baseInfo, idcard } }); } }) } ]; isSpecial && items.shift(); return (