import React, { Component } from 'react';
import { Switch, Form, Input, Row, Col, Button, message, DatePicker, Select } from 'antd';
import moment from 'moment';
import { $http } from '../../containers/config/https';
import { Util } from '../../tools';
// const FormItem = Form.Item;
// const RadioGroup = Radio.Group;
const Option = Select.Option;

const editfield = Form.create()(
    class extends Component {
        constructor(props) {
            super(props);
            this.state = {
                editField: [],
                fetching: false,
                data: [],
                value: "",
                selectData: {},
                detailInfo: {},
                rowId: "",
                ColNum: 6,
                className: "",
                operateAuth: "",
                remoteSearchArr: null

            };
            this.propFlag = 0
        }

        componentDidMount() {
            let detailInfo = this.state.detailInfo ? this.state.detailInfo : {};
            this.setState({
                detailInfo: detailInfo,
                className: this.props.className
            }, () => {
                this.getEditField(this.props.className)
                this.getSelectData(this.props.className)
            })
        }

        //props 改变时调用此方法
        componentWillReceiveProps(nextProps) {
            var rowId = "", className = ""
            if (nextProps.rowId !== undefined) {
                rowId = nextProps.rowId
            } else {
                rowId = ""
            }
            if (nextProps.className !== undefined) {
                className = nextProps.className
            } else {
                className = ""
            }
            if ((this.state.className === nextProps.className) && (this.state.rowId === nextProps.rowId)) {

                this.getEditField(nextProps.className)
                return
            }
            if (this.state.className !== nextProps.className) {

                this.getEditField(nextProps.className)
                this.getSelectData(nextProps.className)
            }
            this.setState({
                className: className,
                rowId: rowId
            })
            //
            if (rowId === "") {
                this.setState({
                    detailInfo: {}
                })
                return
            }
            this.resetFields()
            let data = {
                params: [{ ClassName: className, ID: rowId }]
            }
            $http.post("urlS", this, {
                code: "4006",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        var itemData = res.result
                        this.setState({
                            rowId: rowId,
                            detailInfo: itemData,
                        });
                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            })
        }

        normalizeAll = (value, prevValue) => {
            return value
        }

        GetCom = (fieldItem) => {
            const { getFieldDecorator } = this.props.form;
            let detailInfo = this.state.detailInfo ? this.state.detailInfo : {};
            var code = detailInfo[fieldItem.Code]
            if (typeof detailInfo[fieldItem.Code] === "undefined") {
                code = ""
            }
            var type = fieldItem.Type
            var ReadOnlyFlag = fieldItem.ReadOnlyFlag
            var disabled = false

            //var remoteSearch=fieldItem.remoteSearch
            //if(remoteSearch==="Y") disabled=true
            if (type === "Text") {
                return (
                    {
                        ...getFieldDecorator(fieldItem.Code, {
                            initialValue: code,
                            rules: fieldItem.rules,
                        })(<Input disabled={disabled} onKeyDown={this.FieldOnKeyDown.bind(this, fieldItem.Code)} style={{ width: '100%' }} />)
                    }
                )
            } else if (type === "Radio") {
                return (

                    {
                        ...getFieldDecorator(fieldItem.Code, {
                            initialValue: code === "Y" ? true : false,
                            valuePropName: 'checked',
                            rules: fieldItem.rules,
                            normalize: (value, prevValue) => {
                                return value
                            }
                        })(<Switch disabled={disabled} checkedChildren="是" unCheckedChildren="否" />)
                    }
                )
            } else if (type === "Date") {
                var date = ""
                if (fieldItem.Code === "StartDate" || fieldItem.Code === 'StDate') {
                    date = code ? moment(code, 'YYYY-MM-DD') : moment(new Date(), 'YYYY-MM-DD')
                } else {
                    date = code ? moment(code, 'YYYY-MM-DD') : null
                }
                return (
                    {
                        ...getFieldDecorator(fieldItem.Code, {
                            initialValue: date,
                            rules: fieldItem.rules
                        })(<DatePicker disabled={disabled} format="YYYY-MM-DD" />)
                    }
                )
            } else if (type === "DR") {
                //if(RemoteFlag==="Y"){
                //    return this.GetSelectRemote(fieldItem,detailInfo);
                //}else{
                return this.GetSelect(fieldItem, detailInfo);
                //}


            } else if (type === "Select") {
                return this.GetSelectOther(fieldItem, detailInfo);
            } else if (type === "Time") {
                var rules = []
                rules = fieldItem.rules
                rules.push({
                    validator: this.validateTime
                })
                return (
                    {
                        ...getFieldDecorator(fieldItem.Code, {
                            initialValue: code,
                            rules: rules,
                        })(<Input disabled={disabled} />)
                    }
                )
            } else {
                return (
                    {
                        ...getFieldDecorator(fieldItem.Code, {
                            initialValue: code,
                            rules: fieldItem.rules,
                        })(<Input disabled={disabled} />)
                    }
                )
            }
        }

        validateTime = (rule, time, callback) => {
            if (time === "") {
                callback()
                return
            }
            for (var i = 0; i < time.length; i++) {
                var ascCode = time[i].charCodeAt()
                if (((ascCode < 48) || (ascCode > 57)) && (ascCode !== 58)) {
                    callback("时间格式不正确")
                }
            }
            var timeArr = time.split(":")
            if (timeArr.length === 3) {
                if ((timeArr[0] >= "24") || (timeArr[1] >= "60") || (timeArr[2] >= "60")) {
                    callback("时间格式不正确")
                }
            } else if (timeArr.length === 2) {
                if ((timeArr[0] >= "24") || (timeArr[1] >= "60")) {
                    callback("时间格式不正确")
                }
            } else {
                callback("时间格式不正确")
            }
            callback()
        }

        getEditField = (className) => {
            const hospDr = this.props.hospDr ? this.props.hospDr : ""
            const groupDr = this.props.groupDr ? this.props.groupDr : ""
            let data = {
                params: [{
                    ClassName: className,
                    groupId: groupDr,
                    hospitalId: hospDr
                }]
            }
            $http.post("urlS", this, {
                code: "4004",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        var fieldArr = []
                        fieldArr = res.result.Data
                        this.setState({
                            editField: fieldArr,
                            ColNum: res.result.ColNum
                        })


                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                }
            })
        }

        handleChange = (value, option) => {
        }

        handleFocus = () => {

        }

        handleBlur = () => {

        }

        GetSelect = (fieldItem, detailInfo) => {
            const { selectData } = this.state;
            const { getFieldDecorator, getFieldValue, setFieldsValue } = this.props.form;
            //let detailInfo = this.state.detailInfo
            var code = detailInfo[fieldItem.Code]
            if (typeof detailInfo[fieldItem.Code] === "undefined") {
                code = ""
            }
            var ReadOnlyFlag = fieldItem.ReadOnlyFlag
            var remoteSearch = fieldItem.remoteSearch
            var disabled = false
            if (ReadOnlyFlag === "Y") disabled = true
            var PrevLevelField = fieldItem.PrevLevelField
            var prevLevelFieldJson = []
            if (PrevLevelField !== "") {
                var prevLevelFieldArr = PrevLevelField.split("^")
                for (var i = 0; i < prevLevelFieldArr.length; i++) {
                    var jsonObj = {}
                    jsonObj.field = prevLevelFieldArr[i]
                    jsonObj.fieldVal = getFieldValue(prevLevelFieldArr[i])
                    prevLevelFieldJson.push(jsonObj)
                }
            }
            var stateObj = this.state
            var remoteSearchArr = stateObj[fieldItem.Code]
            var fieldDataNew = []
            if (remoteSearchArr) {
                fieldDataNew = remoteSearchArr
            } else {
                //遍历数据
                var fieldData = selectData[fieldItem.Code]
                if (fieldData) {
                    var count = 0
                    for (var i = 0; i < fieldData.length; i++) {
                        var itemData = fieldData[i]
                        var flag = 0
                        if (PrevLevelField === "") {
                            var flag = 1
                        } else {
                            var flag = 1
                            for (var j = 0; j < prevLevelFieldJson.length; j++) {
                                var prevvalue = itemData[prevLevelFieldJson[j].field] ? itemData[prevLevelFieldJson[j].field] : ""
                                var prevFieldValue = prevLevelFieldJson[j].fieldVal
                                if ((prevFieldValue === "") || (prevvalue === prevFieldValue)) {

                                } else {
                                    flag = 0
                                }
                            }
                        }
                        if (flag == 1) {
                            if (remoteSearch == "Y") {
                                count = count + 1
                                if (count <= 100) {
                                    fieldDataNew.push(itemData)
                                } else {
                                    break;
                                }
                            } else {
                                fieldDataNew.push(itemData)
                            }
                        }
                    }
                }

            }


            return (
                {
                    ...getFieldDecorator(fieldItem.Code, {
                        initialValue: code,
                        rules: fieldItem.rules,
                        normalize: (value, prevValue) => {
                            if (value === 0) {
                                value = ""
                            }
                            return value
                        }
                    })(

                        <Select
                            allowClear={true}
                            placeholder=""
                            showSearch
                            optionFilterProp="children"
                            onChange={(value, option) => {
                                var editFieldArr = this.state.editField
                                var fieldName = fieldItem.Code
                                var count = 0
                                var fieldJson = {}
                                var fieldObj;
                                for (var i = 0; i < editFieldArr.length; i++) {
                                    fieldObj = editFieldArr[i]
                                    fieldJson[fieldObj.Code] = fieldObj
                                }
                                while (fieldName !== "") {
                                    fieldObj = fieldJson[fieldName]
                                    var NextField = fieldObj.NextLevelField
                                    if (NextField !== "") {
                                        var valObj = {}
                                        valObj[NextField] = ""
                                        setFieldsValue(valObj)
                                        fieldName = NextField
                                    } else {
                                        fieldName = ""
                                    }

                                    count = count + 1
                                    if (count > 10) {
                                        break;
                                    }
                                }
                            }}
                            onSearch={this.SelectSearch.bind(this, fieldItem)}
                            onSelect={this.FieldSelect.bind(this, fieldItem.Code)}
                            onFocus={this.handleFocus}
                            onBlur={this.handleBlur}
                            disabled={disabled}
                            filterOption={(input, option) => {
                                var desc = option.props.children
                                var alias = option.props.alias
                                var flag = (desc.toLowerCase().indexOf(input.toLowerCase()) >= 0) || (alias.toLowerCase().indexOf(input.toLowerCase()) >= 0)
                                var prevvalue = option.props.prevvalue
                                var prevFieldValue = ""
                                if (typeof prevvalue !== "undefined") {
                                    prevFieldValue = getFieldValue(PrevLevelField)
                                    flag = flag && (prevFieldValue === prevvalue)
                                }
                                return flag
                            }}
                            style={{ width: '100%' }}
                        >
                            {
                                fieldDataNew.map((d) => {
                                    return (
                                        <Option key={d.ID} alias={d.Alias}  >{d.Desc}</Option>
                                    )
                                })
                            }
                        </Select>
                    )
                }
            );
        }

        SelectSearch = (fieldItem, value) => {
            const { selectData } = this.state;
            var FieldName = fieldItem.Code
            var PrevLevelField = fieldItem.PrevLevelField
            var remoteSearch = fieldItem.remoteSearch
            var prevLevelFieldJson = []
            if (PrevLevelField !== "") {
                var prevLevelFieldArr = PrevLevelField.split("^")
                for (var i = 0; i < prevLevelFieldArr.length; i++) {
                    var jsonObj = {}
                    jsonObj.field = prevLevelFieldArr[i]
                    jsonObj.fieldVal = getFieldValue(prevLevelFieldArr[i])
                    prevLevelFieldJson.push(jsonObj)
                }
            }

            var fieldDataNew = []
            //遍历数据
            var fieldData = selectData[FieldName]
            if (fieldData) {
                var count = 0
                for (var i = 0; i < fieldData.length; i++) {
                    var itemData = fieldData[i]
                    var flag = 0
                    if (PrevLevelField === "") {
                        var flag = 1
                    } else {
                        var flag = 1
                        for (var i = 0; i < prevLevelFieldJson.length; i++) {
                            var prevvalue = d[prevLevelFieldJson[i].field] ? d[prevLevelFieldJson[i].field] : ""
                            var prevFieldValue = prevLevelFieldJson[i].fieldVal
                            if ((prevFieldValue === "") || (prevvalue === prevFieldValue)) {

                            } else {
                                flag = 0
                            }
                        }
                    }
                    if (flag = 0) continue
                    var desc = itemData.Desc
                    var alias = itemData.Alias
                    var flag = (desc.toLowerCase().indexOf(value.toLowerCase()) >= 0) || (alias.toLowerCase().indexOf(value.toLowerCase()) >= 0)
                    //var prevvalue=option.props.prevvalue
                    var prevFieldValue = ""
                    var findFlag = false
                    if (typeof prevvalue !== "undefined") {
                        prevFieldValue = getFieldValue(PrevLevelField)
                        flag = flag && (prevFieldValue === prevvalue)
                    }

                    if (flag == 1) {
                        if (remoteSearch == "Y") {
                            count = count + 1
                            if (count <= 100) {
                                fieldDataNew.push(itemData)
                            } else {
                                break;
                            }
                        } else {
                            fieldDataNew.push(itemData)
                        }
                    }
                }
            }

            var dataObj = {}
            dataObj[FieldName] = fieldDataNew
            this.setState(dataObj)
        }

        getRemoteSearchData = (fieldItem, selectData) => {
            const { getFieldValue } = this.props.form;
            //let detailInfo = this.state.detailInfo
            var code = detailInfo[fieldItem.Code]
            if (typeof detailInfo[fieldItem.Code] === "undefined") {
                code = ""
            }
            var ReadOnlyFlag = fieldItem.ReadOnlyFlag
            var remoteSearch = fieldItem.remoteSearch
            var disabled = false
            if (ReadOnlyFlag === "Y") disabled = true
            var PrevLevelField = fieldItem.PrevLevelField
            var prevLevelFieldJson = []
            if (PrevLevelField !== "") {
                var prevLevelFieldArr = PrevLevelField.split("^")
                for (var i = 0; i < prevLevelFieldArr.length; i++) {
                    var jsonObj = {}
                    jsonObj.field = prevLevelFieldArr[i]
                    jsonObj.fieldVal = getFieldValue(prevLevelFieldArr[i])
                    prevLevelFieldJson.push(jsonObj)
                }
            }
            //遍历数据
            var fieldData = selectData[fieldItem.Code]
            var fieldDataNew = []
            var count = 0
            for (var i = 0; i < fieldData.length; i++) {
                var itemData = fieldData[i]
                var flag = 0
                if (PrevLevelField === "") {
                    var flag = 1
                } else {
                    var flag = 1
                    for (var i = 0; i < prevLevelFieldJson.length; i++) {
                        var prevvalue = d[prevLevelFieldJson[i].field] ? d[prevLevelFieldJson[i].field] : ""
                        var prevFieldValue = prevLevelFieldJson[i].fieldVal
                        if ((prevFieldValue === "") || (prevvalue === prevFieldValue)) {

                        } else {
                            flag = 0
                        }
                    }
                }
                if (flag == 1) {
                    if (remoteSearch == "Y") {
                        count = count + 1
                        if (count <= 100) {
                            fieldDataNew.push(itemData)
                        } else {
                            break;
                        }
                    } else {
                        fieldDataNew.push(itemData)
                    }
                }
            }
            return fieldDataNew
        }

        GetSelectRemote = (fieldItem, detailInfo) => {
            const { selectData } = this.state;
            const { getFieldDecorator, getFieldValue, setFieldsValue } = this.props.form;
            //let detailInfo = this.state.detailInfo
            var code = detailInfo[fieldItem.Code]
            if (typeof detailInfo[fieldItem.Code] === "undefined") {
                code = ""
            }
            var ReadOnlyFlag = fieldItem.ReadOnlyFlag
            var disabled = false
            if (ReadOnlyFlag === "Y") disabled = true
            var PrevLevelField = fieldItem.PrevLevelField
            var prevLevelFieldJson = []
            if (PrevLevelField !== "") {
                var prevLevelFieldArr = PrevLevelField.split("^")
                for (var i = 0; i < prevLevelFieldArr.length; i++) {
                    var jsonObj = {}
                    jsonObj.field = prevLevelFieldArr[i]
                    jsonObj.fieldVal = getFieldValue(prevLevelFieldArr[i])
                    prevLevelFieldJson.push(jsonObj)
                }
            }

            return (
                {
                    ...getFieldDecorator(fieldItem.Code, {
                        initialValue: code,
                        rules: fieldItem.rules,
                        normalize: (value, prevValue) => {
                            if (value === 0) {
                                value = ""
                            }
                            return value
                        }
                    })(
                        <Select
                            allowClear={true}
                            placeholder=""
                            showSearch
                            optionFilterProp="children"
                            onChange={(value, option) => {


                            }}
                            onSelect={this.FieldSelect.bind(this, fieldItem.Code)}
                            onFocus={this.handleFocus}
                            onBlur={this.handleBlur}
                            disabled={disabled}
                            style={{ width: '100%' }}
                        >
                            {
                                <Option key={d.ID} alias={d.Alias} prevvalue={prevvalue} >{d.Desc}</Option>
                            }
                        </Select>
                    )
                }
            );
        }

        GetSelectOther = (fieldItem, detailInfo) => {
            const { selectData } = this.state;
            const { getFieldDecorator } = this.props.form;
            //let detailInfo = this.state.detailInfo
            var code = detailInfo[fieldItem.Code]
            if (typeof detailInfo[fieldItem.Code] === "undefined") {
                code = ""
            }
            var ReadOnlyFlag = fieldItem.ReadOnlyFlag
            var disabled = false
            if (ReadOnlyFlag === "Y") disabled = true
            return (
                {
                    ...getFieldDecorator(fieldItem.Code, {
                        initialValue: code,
                        rules: fieldItem.rules,
                        normalize: (value, prevValue) => {
                            if (+value === 0) {
                                value = ""
                            }
                            return value
                        }
                    })(

                        <Select
                            placeholder=""
                            optionFilterProp="children"
                            onChange={this.handleChange}
                            onFocus={this.handleFocus}
                            onBlur={this.handleBlur}
                            disabled={disabled}
                            filterOption={(input, option) => option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}
                            style={{ width: '100%' }}
                        >
                            {
                                selectData[fieldItem.Code] && selectData[fieldItem.Code].length && selectData[fieldItem.Code].map(d => <Option key={d.ID}>{d.Desc}</Option>)
                            }
                        </Select>
                    )
                }
            );
        }

        getSelectData = (className) => {
            const hospDr = this.props.hospDr ? this.props.hospDr : ""
            const groupDr = this.props.groupDr ? this.props.groupDr : ""
            let data = {
                params: [{
                    ClassName: className,
                    groupId: groupDr,
                    hospitalId: hospDr
                }]
            }
            $http.post("urlS", this, {
                code: "4007",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        var selectData = res.result
                        this.setState({
                            selectData: selectData
                        })
                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            })
        }

        shouldComponentUpdate(nextProps, nextState) {
            if (nextState === this.state) {
                //return false
            }
            return true
        }

        handelSave = () => {
            const userData = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {}
            const { form: { validateFields } } = this.props;
            validateFields((errors, values) => {
                if (errors === null) {
                    let data = {
                        params: []
                    }
                    //转换values  里的Radio类型的字段的值,true转换成Y,false转换成N
                    let editField = this.state.editField
                    for (var i = 0; i < editField.length; i++) {
                        var itemField = editField[i]
                        if (itemField.Type === "Radio") {
                            if (values[itemField.Code] === true) {
                                values[itemField.Code] = "Y"
                            } else {
                                values[itemField.Code] = "N"
                            }
                        } else if (itemField.Type === "Date") {
                            if (values[itemField.Code]) {
                                values[itemField.Code] = values[itemField.Code].format('YYYY-MM-DD')
                                //console.log(values[itemField.Code].format('YYYY-MM-DD')) 
                            }
                        }
                    }

                    var dataObj = {}
                    dataObj.ClassName = this.props.className
                    dataObj.userID = userData.userID
                    let ItemObj = JSON.parse(JSON.stringify(values));
                    var ID = this.state.detailInfo.ID
                    if (typeof ID === "undefined") {

                    } else {
                        ItemObj.ID = ID
                    }
                    dataObj.Item = ItemObj
                    // 处理需要传递的obj
                    data.params.push(Util.disposeData(dataObj));
                    $http.post("urlADS", this, {
                        code: 4005,
                        data: data,
                        success: function (res) {
                            if (+res.errorCode === 0) {
                                // 提示
                                message.success('保存成功');
                                // 新增或编辑成功重置form表单

                                this.props.handelThis.getAllData()
                                this.resetFields();

                            } else {
                                message.error("保存失败:" + res.errorMessage);
                            }
                        }
                    })
                } else {
                    return;
                }
            })
        }

        // 重置表单
        resetFields = () => {
            this.setState({
                rowId: "",
                detailInfo: {},
            });
            //this.props.form.resetFields(); //清空所有
            //this.props.handelThis.resetEditFieldData()
        }

        //字段跳转方法
        FieldOnKeyDown = (field, e) => {
            if (e.keyCode === 13) {
                var fieldArr = this.state.editField
                for (var i = 0; i < fieldArr.length; i++) {
                    if (field === fieldArr[i].Code) {
                        if (fieldArr[i + 1]) {
                            console.log(this)
                            var fieldObj = this.props.form.getFieldInstance(fieldArr[i + 1].Code)
                            fieldObj.focus()
                        }
                    }
                }
            }
        }

        FieldSelect = (field) => {
            var fieldArr = this.state.editField
            var nextField = ""
            for (var i = 0; i < fieldArr.length; i++) {
                if (field === fieldArr[i].Code) {
                    if (fieldArr[i + 1]) {
                        nextField = fieldArr[i + 1].Code
                        break;

                    }
                }
            }
            if (nextField !== "") {
                var fieldObj = this.props.form.getFieldInstance(fieldArr[i + 1].Code)
                setTimeout(() => {
                    fieldObj.focus()
                }, 100)
            }
        }

        GetOperateAuth = (className, hospital) => {
            const userData = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {}
            let data = {
                params: [{
                    ClassName: className,
                    Group: userData.groupID,
                    hospital: hospital
                }]
            }
            $http.post("urlS", this, {
                code: "4020",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        this.setState({
                            operateAuth: res.operateAuth
                        })

                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            })
        }

        DeleteData = () => {
            const userData = sessionStorage.userData ? JSON.parse(sessionStorage.userData) : {}
            var rowId = this.state.rowId
            var className = this.state.className
            if (rowId === "") {
                message.error('请选择要删除的数据');
                return
            }
            let data = {
                params: [{
                    className: className,
                    id: rowId,
                    userID: userData.userID
                }]
            }
            $http.post("urlS", this, {
                code: "4032",
                data: data,
                success: function (res) {
                    if (+res.errorCode === 0) {
                        // 提示
                        message.success('删除成功');
                        // 新增或编辑成功重置form表单
                        this.props.handelThis.setState({ rowId: "" })
                        this.props.handelThis.getAllData()
                        this.resetFields();

                    } else {
                        message.error('失败：' + res.errorMessage);
                    }
                },
                error: function (error) {
                    message.error('失败：' + error);
                }
            })
        }

        getButton = () => {
            var operateAuth = this.state.operateAuth
            var rowId = this.state.rowId
            var disabled = true
            if (rowId === "") {
                if (operateAuth.indexOf("Add") >= 0) {
                    disabled = false
                } else {
                    disabled = true
                }
            } else {
                if (operateAuth.indexOf("Update") >= 0) {
                    disabled = false
                } else {
                    disabled = true
                }
            }
            disabled = false
            return (
                <Button onClick={this.handelSave} disabled={disabled} type="primary">保存</Button>
            )

        }

        getDeleteButton = () => {
            var operateAuth = this.state.operateAuth
            var rowId = this.state.rowId
            var disabled = false
            if (operateAuth.indexOf("Delete") >= 0) {
                disabled = false
            } else {
                //disabled=true
            }
            return (
                <Button onClick={this.DeleteData} disabled={disabled} type="primary">删除</Button>
            )

        }

        render() {
            let ColWidth = Math.ceil(24 / this.state.ColNum)
            return (
                <div>
                    <Form onSubmit={this.handleSubmit} layout="vertical" >
                        <Row gutter={24} >
                            {
                                this.state.editField.length > 0 ? this.state.editField.map((value, key) => {
                                    return (
                                        <Col span={ColWidth} key={key} >
                                            <Form.Item key={key} label={value.Desc} style={{ height: '60px' }} >

                                                {this.GetCom(value)}
                                            </Form.Item>
                                        </Col>
                                    )
                                }) : ""
                            }
                        </Row>
                        <Row>
                            <Col span={8} >
                                {
                                    this.getButton()
                                }

                            </Col>
                            {/* 
                                @ByShizi: 取消删除按钮，需要删除修改失效日期
                                Create 2022-07-01
                            */}
                            {/* <Col span={8} >
                                {
                                    this.getDeleteButton()
                                }

                            </Col> */}
                            <Col span={8} >
                                <Button type="primary" onClick={this.resetFields}>重置</Button>
                            </Col>
                        </Row>
                    </Form>
                </div>
            );
        }
    })

export default editfield;