king
2022-05-17 af89cc791fc928578740a62917e9ee32a8a23d6b
src/menu/components/table/edit-table/index.jsx
@@ -46,7 +46,6 @@
      let _card = {
        uuid: card.uuid,
        type: card.type,
        floor: card.floor,
        tabId: card.tabId || '',
        parentId: card.parentId || '',
        format: 'array',    // 组件属性 - 数据格式
@@ -133,6 +132,7 @@
  componentDidMount () {
    MKEmitter.addListener('submitStyle', this.getStyle)
    MKEmitter.addListener('submitModal', this.handleSave)
    MKEmitter.addListener('completeSave', this.completeSave)
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -148,6 +148,20 @@
    }
    MKEmitter.removeListener('submitStyle', this.getStyle)
    MKEmitter.removeListener('submitModal', this.handleSave)
    MKEmitter.removeListener('completeSave', this.completeSave)
  }
  completeSave = () => {
    const { card } = this.state
    if (card.isNew) {
      let item = fromJS(card).toJS()
      item.cols = item.cols.filter(a => !a.origin)
      delete item.isNew
      this.setState({card: item})
    }
  }
  filterOrigin = (component) => {
@@ -180,7 +194,12 @@
  changeStyle = () => {
    const { card } = this.state
    MKEmitter.emit('changeStyle', [card.uuid], ['background', 'border', 'padding', 'margin', 'shadow'], card.style)
    let style = {...card.style}
    style.color = card.wrap.color || 'rgba(0, 0, 0, 0.65)'
    style.fontSize = card.wrap.fontSize || 14
    style.fontWeight = card.wrap.fontWeight || 'normal'
    MKEmitter.emit('changeStyle', [card.uuid], ['font1', 'background', 'border', 'padding', 'margin', 'shadow'], style)
  }
  getStyle = (comIds, style) => {
@@ -188,7 +207,21 @@
    if (comIds[0] !== card.uuid || comIds.length !== 1) return
    let _card = {...card, style}
    let _card = fromJS(card).toJS()
    let _style = fromJS(style).toJS()
    let color = style.color
    let fontSize = style.fontSize
    let fontWeight = style.fontWeight
    delete _style.color
    delete _style.fontSize
    delete _style.fontWeight
    _card.style = _style
    _card.wrap.color = color
    _card.wrap.fontSize = fontSize
    _card.wrap.fontWeight = fontWeight
    this.setState({
      card: _card
@@ -296,7 +329,19 @@
  }
  updateWrap = (res) => {
    this.updateComponent({...this.state.card, wrap: res})
    const { card } = this.state
    res.color = card.wrap.color
    res.fontSize = card.wrap.fontSize
    res.fontWeight = card.wrap.fontWeight
    let _card = {...card, wrap: res}
    if (res.tableType) {
      _card.switchable = true
    }
    this.updateComponent(_card)
  }
  clickComponent = (e) => {
@@ -334,6 +379,7 @@
        <SearchComponent config={card} updatesearch={this.updateconfig}/>
        <ActionComponent type="editable" config={card} setSubConfig={this.setSubConfig} updateaction={this.updateComponent}/>
        <ColumnComponent config={card} updatecolumn={this.updateconfig}/>
        <div className="component-name"><div className="center">{card.name}</div></div>
      </div>
    )
  }