king
2024-07-29 fd1a4a42bbef3e9c02e0fee346b49401ec0fe23f
src/tabviews/zshare/mutilform/mkCheckCard/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Col, Row } from 'antd'
import { Col, Row, Switch } from 'antd'
import { CheckOutlined } from '@ant-design/icons'
import MKEmitter from '@/utils/events.js'
@@ -28,6 +28,8 @@
      selectKeys = config.initval ? config.initval.split(',') : []
      initlength = selectKeys.length
      selectKeys = this.filterVals(config.options, selectKeys)
    } else if (config.options[0] && typeof(config.options[0].$value) === 'number' && /^([0-9]|[1-9]\d{0,2})$/.test(config.initval)) {
      selectKeys = +config.initval
    }
    if (!config.selectStyle && config.backgroundColor) {
@@ -281,6 +283,29 @@
    }
  }
  onChange = (val) => {
    if (val) {
      let keys = []
      this.state.options.forEach(item => {
        if (item.$disabled) return
        keys.push(item.$value)
      })
      this.setState({
        selectKeys: keys
      }, () => {
        this.props.onChange(keys.join(','))
      })
    } else {
      this.setState({
        selectKeys: []
      }, () => {
        this.props.onChange('')
      })
    }
  }
  render() {
    const { config, options } = this.state
@@ -295,6 +320,7 @@
    return (
      <div className={'check-card-form-box ' + extend}>
        {config.checkAll === 'show' && options.length > 3 ? <Switch size="small" onChange={this.onChange}/> : null}
        <Row gutter={12}>{this.getCards()}</Row>
      </div>
    )