king
2024-10-02 65da4dae29c621df1764cb5523c64e92be8b180a
src/menu/components/editor/braft-editor/index.jsx
@@ -6,7 +6,7 @@
import asyncComponent from '@/utils/asyncComponent'
import asyncIconComponent from '@/utils/asyncIconComponent'
import { getTables } from '@/utils/utils-custom.js'
import { getTables, checkComponent } from '@/utils/utils-custom.js'
import getWrapForm from './options'
import MKEmitter from '@/utils/events.js'
@@ -16,7 +16,6 @@
const NormalForm = asyncIconComponent(() => import('@/components/normalform'))
const NormalHeader = asyncComponent(() => import('@/menu/components/share/normalheader'))
const CopyComponent = asyncIconComponent(() => import('@/menu/components/share/copycomponent'))
const UserComponent = asyncIconComponent(() => import('@/menu/components/share/usercomponent'))
const EditorContent = asyncIconComponent(() => import('./editorcontent'))
const BraftContent = asyncComponent(() => import('@/tabviews/custom/components/share/braftContent'))
@@ -39,7 +38,7 @@
      let _card = {
        uuid: card.uuid,
        type: card.type,
        format: 'object',   // 组件属性 - 数据格式
        format: 'array',    // 组件属性 - 数据格式
        pageable: false,    // 组件属性 - 是否可分页
        switchable: false,  // 组件属性 - 数据是否可切换
        width: card.width || 24,
@@ -54,24 +53,18 @@
        html: ''
      }
      if (card.config) {
        let config = fromJS(card.config).toJS()
        _card.wrap = config.wrap
        _card.wrap.name = card.name
        _card.style = config.style
        _card.headerStyle = config.headerStyle
        _card.html = config.html
        _card.setting = config.setting
        _card.columns = config.columns
        _card.scripts = config.scripts
      }
      this.updateComponent(_card)
    } else {
      let _card = fromJS(card).toJS()
      _card.format = 'array'
      if (_card.wrap.firstTr === 'light') {
        _card.wrap.tbStyle = 'th-light'
        delete _card.wrap.firstTr
      }
      this.setState({
        card: fromJS(card).toJS()
        card: _card
      })
    }
  }
@@ -116,21 +109,11 @@
    card.name = card.wrap.name
    card.errors = []
    card.$tables = []
    let columns = card.columns.map(c => c.field)
    if (card.wrap.datatype !== 'static') {
      if (card.setting.interType === 'system' && card.setting.execute !== 'false' && !card.setting.dataresource) {
        card.errors.push({ level: 0, detail: '未设置数据源!'})
      } else if (card.setting.interType === 'system' && card.setting.execute === 'false' && card.scripts.filter(script => script.status !== 'false').length === 0) {
        card.errors.push({ level: 0, detail: '数据源中无可用脚本!'})
      } else if (!card.setting.primaryKey) {
        card.errors.push({ level: 0, detail: '未设置主键!'})
      } else if (!columns.includes(card.setting.primaryKey)) {
        card.errors.push({ level: 0, detail: '主键已失效!'})
      } else if (!card.setting.supModule) {
        card.errors.push({ level: 0, detail: '未设置上级组件!'})
      }
    if (card.wrap.datatype === 'dynamic') {
      card.$c_ds = true
      card.errors = checkComponent(card)
      if (card.errors.length === 0) {
        card.$tables = getTables(card)
@@ -164,6 +147,10 @@
  updateWrap = (res) => {
    const { card } = this.state
    if (res.tbStyle) {
      res.tbStyle = res.tbStyle.join(' ')
    }
    let _card = {...card, wrap: res}
@@ -199,16 +186,15 @@
    let style = {...card.style}
    return (
      <div className="menu-normal-editor-box" style={style} onClick={this.clickComponent} id={card.uuid}>
      <div className={'menu-normal-editor-box ' + (card.wrap.tbStyle || '')} style={style} onClick={this.clickComponent} id={card.uuid}>
        <NormalHeader hideSearch="true" config={card} updateComponent={this.updateComponent}/>
        <Popover overlayClassName="mk-popover-control-wrap" mouseLeaveDelay={0.2} mouseEnterDelay={0.2} content={
          <div className="mk-popover-control">
            <NormalForm title="富文本设置" width={750} update={this.updateWrap} getForms={this.getWrapForms}>
            <NormalForm title="富文本设置" width={850} update={this.updateWrap} getForms={this.getWrapForms}>
              <EditOutlined style={{color: '#1890ff'}} title="编辑"/>
            </NormalForm>
            <CopyComponent type="normaltable" card={card}/>
            <CopyComponent type="editor" card={card}/>
            <FontColorsOutlined className="style" title="调整样式" onClick={this.changeStyle}/>
            <UserComponent config={card}/>
            <DeleteOutlined className="close" title="删除组件" onClick={() => this.props.deletecomponent(card.uuid)} />
            <EditorContent config={card} updateConfig={this.updateComponent}/>
            {card.wrap.datatype === 'dynamic' ? <SettingComponent config={card} updateConfig={this.updateComponent} /> : <SettingOutlined style={{color: '#eeeeee', cursor: 'not-allowed'}} type="setting"/>}