king
2025-04-12 a9ba0e5bc39654b5fa277852135afb49ce11c66c
2025-04-12
6个文件已修改
2个文件已添加
298 ■■■■■ 已修改文件
src/assets/css/design.scss 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/components/share/pasteforms/index.jsx 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/delExtraDb/index.jsx 281 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/menu/delExtraDb/index.scss 补丁 | 查看 | 原始文档 | blame | 历史
src/views/menudesign/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/mobdesign/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/pcdesign/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tabledesign/index.jsx 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/css/design.scss
@@ -171,6 +171,9 @@
    .anticon {
      display: none;
    }
    span {
      margin-left: 0px!important;
    }
  }
  button:hover {
    color: #26C281;
src/menu/components/share/pasteforms/index.jsx
@@ -87,6 +87,7 @@
    let forms = fromJS(config.fields).toJS()
    let fields = fromJS(result.fields).toJS()
    let repeats = []
    let lastId = ''
    forms = forms.map(item => {
      if (!item.field) return item
@@ -94,11 +95,16 @@
      let cell = fields.filter(m => m.field && m.field.toLowerCase() === item.field.toLowerCase())[0]
      if (cell) {
        repeats.push(cell.field)
        lastId = cell.uuid
        return cell
      }
      return item
    })
    if (lastId) {
      window.GLOB.formId = lastId
    }
    
    fields = fields.filter(m => !m.field || !repeats.includes(m.field))
src/menu/delExtraDb/index.jsx
New file
@@ -0,0 +1,281 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { fromJS } from 'immutable'
import { Modal, Button, notification } from 'antd'
// import './index.scss'
const { confirm } = Modal
class DelExtraDb extends Component {
  static propTpyes = {
    config: PropTypes.object,
    updateConfig: PropTypes.func
  }
  trigger = () => {
    const that = this
    confirm({
      title: '确定要清除外库吗?',
      content: '配置中的@db@将被清除',
      okText: '确定',
      cancelText: '取消',
      onOk() {
        that.exec()
      },
      onCancel() {}
    })
  }
  checkBtn = (cell) => {
    if (cell.modal && cell.modal.fields && cell.modal.fields.length) {
      cell.modal.fields = cell.modal.fields.map(n => {
        if (n.dataSource) {
          n.dataSource = n.dataSource.replace(/@db@/ig, '')
        }
        return n
      })
    }
    if (cell.sql) {
      cell.sql = cell.sql.replace(/@db@/ig, '')
    }
    if (cell.cbTable) {
      cell.cbTable = cell.cbTable.replace(/@db@/ig, '')
    }
    if (cell.sheet) {
      cell.sheet = cell.sheet.replace(/@db@/ig, '')
    }
    if (cell.verify) {
      if (cell.verify.scripts) {
        cell.verify.scripts = cell.verify.scripts.map(n => {
          if (n.sql) {
            n.sql = n.sql.replace(/@db@/ig, '')
          }
          return n
        })
      }
      if (cell.verify.cbScripts) {
        cell.verify.cbScripts = cell.verify.cbScripts.map(n => {
          if (n.sql) {
            n.sql = n.sql.replace(/@db@/ig, '')
          }
          return n
        })
      }
      if (cell.verify.customverifys) {
        cell.verify.customverifys = cell.verify.customverifys.map(n => {
          if (n.sql) {
            n.sql = n.sql.replace(/@db@/ig, '')
          }
          return n
        })
      }
    }
  }
  exec = () => {
    let config = fromJS(this.props.config).toJS()
    let _replace = (components) => {
      return components.map(item => {
        if (item.type === 'tabs') {
          item.subtabs.forEach(tab => {
            tab.components = _replace(tab.components)
          })
          return item
        } else if (item.type === 'group') {
          item.components = _replace(item.components)
          return item
        }
        if (item.setting) {
          if (item.setting.tableName) {
            item.setting.tableName = item.setting.tableName.replace(/@db@/ig, '')
          }
          if (item.setting.dataresource) {
            item.setting.dataresource = item.setting.dataresource.replace(/@db@/ig, '')
          }
          if (item.scripts) {
            item.scripts = item.scripts.map(cell => {
              cell.sql = cell.sql.replace(/@db@/ig, '')
              return cell
            })
          }
        }
        if (item.search) {
          if (Array.isArray(item.search)) {
            item.search = item.search.map(col => {
              if (col.dataSource) {
                col.dataSource = col.dataSource.replace(/@db@/ig, '')
              }
              return col
            })
          } else if (item.search.fields) {
            item.search.fields = item.search.fields.map(col => {
              if (col.dataSource) {
                col.dataSource = col.dataSource.replace(/@db@/ig, '')
              }
              return col
            })
            if (item.search.groups) {
              item.search.groups = item.search.groups.map(group => {
                if (group.fields) {
                  group.fields = group.fields.map(col => {
                    if (col.dataSource) {
                      col.dataSource = col.dataSource.replace(/@db@/ig, '')
                    }
                    return col
                  })
                }
                return group
              })
            }
          }
        }
        if (item.action) {
          item.action.forEach(m => {
            this.checkBtn(m)
            if (m.config && m.config.components) {
              m.config.components = _replace(m.config.components)
            }
          })
        }
        if (item.subcards) {
          item.subcards.forEach(card => {
            if (card.subButton) {
              this.checkBtn(card.subButton)
            }
            if (card.elements) { // 卡片
              card.elements = card.elements.map(m => {
                if (m.eleType !== 'button') return m
                this.checkBtn(m)
                if (m.config && m.config.components) {
                  m.config.components = _replace(m.config.components)
                }
                return m
              })
            }
            if (card.backElements) { // 卡片
              card.backElements = card.backElements.map(m => {
                if (m.eleType !== 'button') return m
                this.checkBtn(m)
                if (m.config && m.config.components) {
                  m.config.components = _replace(m.config.components)
                }
                return m
              })
            }
            if (card.fields) { // 表单
              card.fields = card.fields.map(m => {
                if (m.dataSource) {
                  m.dataSource = m.dataSource.replace(/@db@/ig, '')
                }
                return m
              })
            }
          })
        }
        if (item.elements) {
          item.elements = item.elements.map(m => {
            if (m.eleType !== 'button') return m
            this.checkBtn(m)
            if (m.config && m.config.components) {
              m.config.components = _replace(m.config.components)
            }
            return m
          })
        }
        if (item.cols) {
          let _update = (cols) => {
            return cols.map(col => {
              if (col.type === 'custom' && col.elements) {
                col.elements = col.elements.map(m => {
                  if (m.eleType !== 'button') return m
                  this.checkBtn(m)
                  if (m.config && m.config.components) {
                    m.config.components = _replace(m.config.components)
                  }
                  return m
                })
              } else if (col.type === 'colspan') {
                col.subcols = _update(col.subcols)
              }
              return col
            })
          }
          item.cols = _update(item.cols)
        }
        if (item.subtype === 'editable' && item.submit) {
          if (item.submit.sheet) {
            item.submit.sheet = item.submit.sheet.replace(/@db@/ig, '')
          }
          if (item.submit.scripts) {
            item.submit.scripts = item.submit.scripts.map(n => {
              if (n.sql) {
                n.sql = n.sql.replace(/@db@/ig, '')
              }
              return n
            })
          }
        }
        return item
      })
    }
    config.components = _replace(config.components)
    config.interfaces && config.interfaces.forEach(item => {
      if (item.setting) {
        if (item.setting.tableName) {
          item.setting.tableName = item.setting.tableName.replace(/@db@/ig, '')
        }
        if (item.setting.dataresource) {
          item.setting.dataresource = item.setting.dataresource.replace(/@db@/ig, '')
        }
        if (item.scripts) {
          item.scripts = item.scripts.map(cell => {
            cell.sql = cell.sql.replace(/@db@/ig, '')
            return cell
          })
        }
      }
    })
    notification.success({
      top: 92,
      message: '外库已清除。',
      duration: 3
    })
    this.props.updateConfig(config)
  }
  render() {
    // <HddOutlined />
    return (
      <Button className="mk-border-yellow" icon="hdd" onClick={this.trigger}>清除外库</Button>
    )
  }
}
export default DelExtraDb
src/menu/delExtraDb/index.scss
src/views/menudesign/index.jsx
@@ -35,6 +35,7 @@
const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
const DelExtraDb = asyncComponent(() => import('@/menu/delExtraDb'))
const LowerField = asyncComponent(() => import('@/menu/lowerField'))
const Debug = asyncComponent(() => import('@/menu/debug'))
const NormalCss = asyncComponent(() => import('@/menu/normalCss'))
@@ -1367,6 +1368,7 @@
                  {config ? <Dropdown placement="bottomCenter" overlay={<div className="mk-opeartion-dropdown-wrap">
                    <ReplaceField config={config} updateConfig={this.resetConfig}/>
                    <LowerField config={config} updateConfig={this.resetConfig}/>
                    <DelExtraDb config={config} updateConfig={this.resetConfig}/>
                    <PictureController/>
                    <Button onClick={() => window.open('#/ai')}>DeepSeek</Button>
                  </div>} trigger={['hover']}>
src/views/mobdesign/index.jsx
@@ -34,6 +34,7 @@
const TableNodes = asyncComponent(() => import('@/menu/tablenodes'))
const BgController = asyncComponent(() => import('@/pc/bgcontroller'))
const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
const DelExtraDb = asyncComponent(() => import('@/menu/delExtraDb'))
const LowerField = asyncComponent(() => import('@/menu/lowerField'))
const NormalCss = asyncComponent(() => import('@/menu/normalCss'))
const NormalCopy = asyncComponent(() => import('@/menu/normalCopy'))
@@ -2314,6 +2315,7 @@
              <Button className="mk-border-purple" disabled={MenuId === appLoginId} data-title="当前菜单为应用登录页" onClick={this.setLoginView}><LoginOutlined /> 设为登录页</Button>
              <ReplaceField config={config} updateConfig={this.resetConfig}/>
              <LowerField config={config} updateConfig={this.resetConfig}/>
              <DelExtraDb config={config} updateConfig={this.resetConfig}/>
              <Transfer MenuID={MenuId} />
              {config ? <Versions MenuId={MenuId} Template="webPage" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null}
              <Button type="default" onClick={this.closeView}>关闭</Button>
src/views/pcdesign/index.jsx
@@ -39,6 +39,7 @@
const PasteController = asyncComponent(() => import('@/menu/pastecontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
const DelExtraDb = asyncComponent(() => import('@/menu/delExtraDb'))
const LowerField = asyncComponent(() => import('@/menu/lowerField'))
const NormalCss = asyncComponent(() => import('@/menu/normalCss'))
const NormalCopy = asyncComponent(() => import('@/menu/normalCopy'))
@@ -1939,6 +1940,7 @@
                <Button className="mk-border-purple" disabled={MenuId === appLoginId} data-title="当前菜单为应用登录页" onClick={this.setLoginView}><LoginOutlined/> 设为登录页</Button>
                <ReplaceField config={config} updateConfig={this.resetConfig}/>
                <LowerField config={config} updateConfig={this.resetConfig}/>
                <DelExtraDb config={config} updateConfig={this.resetConfig}/>
                <Transfer MenuID={MenuId} />
                {config ? <Versions MenuId={MenuId} Template="webPage" checklog={this.checklog} updateConfig={this.updateLogConfig}/> : null}
                <Button type="default" onClick={this.closeView}>关闭</Button>
src/views/tabledesign/index.jsx
@@ -33,6 +33,7 @@
const BgController = asyncComponent(() => import('@/pc/bgcontroller'))
const StyleController = asyncComponent(() => import('@/menu/stylecontroller'))
const ReplaceField = asyncComponent(() => import('@/menu/replaceField'))
const DelExtraDb = asyncComponent(() => import('@/menu/delExtraDb'))
const LowerField = asyncComponent(() => import('@/menu/lowerField'))
const Debug = asyncComponent(() => import('@/menu/debug'))
const Versions = asyncComponent(() => import('@/menu/versions'))
@@ -1095,6 +1096,7 @@
                    {config ? <Dropdown placement="bottomCenter" overlay={<div className="mk-opeartion-dropdown-wrap">
                      <ReplaceField config={config} updateConfig={this.resetConfig}/>
                      <LowerField config={config} updateConfig={this.resetConfig}/>
                      <DelExtraDb config={config} updateConfig={this.resetConfig}/>
                      <Button onClick={() => window.open('#/ai')}>DeepSeek</Button>
                    </div>} trigger={['hover']}>
                      <div className="mk-button-more">更多<DownOutlined/></div>