king
2025-01-03 aba1f5f8f00548ee243e689efe4ce3e47a71fb17
2025-01-03
2个文件已修改
375 ■■■■■ 已修改文件
src/utils/utils-custom.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/syscheck/index.jsx 373 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/utils-custom.js
@@ -6434,7 +6434,7 @@
  filterComponent(config.components, _mainSearch)
  let keys = sqls.map(item => item.uuid)
  if (keys.length > Array.from(new Set(keys)).length && !window.GLOB.syscheck) {
  if (keys.length > Array.from(new Set(keys)).length) {
    if (window.backend) {
      let m = new Map()
      let n = new Map()
src/views/syscheck/index.jsx
@@ -1,13 +1,13 @@
import React, {Component} from 'react'
import { fromJS } from 'immutable'
import { Spin, notification, Button, Modal } from 'antd'
import moment from 'moment'
import { SwapOutlined } from '@ant-design/icons'
import moment from 'moment'
import md5 from 'md5'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import asyncComponent from '@/utils/asyncComponent'
import { getAllSqls } from '@/utils/utils-custom.js'
import './index.scss'
const Header = asyncComponent(() => import('./header'))
@@ -24,16 +24,18 @@
    outmenus: [],
    backmenus: [],
    appbackmenus: [],
    btnmenus: [],
    appbtnmenus: [],
    unablemenus: [],
  }
  sqlmap = null
  btnmap = null
  // delete _val.controlField 删除按钮控制字段
  UNSAFE_componentWillMount() {
    document.body.className = ''
    window.GLOB.syscheck = true
  }
  componentDidMount() {
@@ -62,6 +64,8 @@
      outmenus: [],
      backmenus: [],
      appbackmenus: [],
      btnmenus: [],
      appbtnmenus: [],
      unablemenus: [],
      loading: true
    })
@@ -109,6 +113,7 @@
          })
        } else {
          this.sqlmap = new Map()
          this.btnmap = new Map()
          let errlist = sessionStorage.getItem('syscheck_main')
          errlist = errlist ? JSON.parse(errlist) : null
@@ -169,6 +174,8 @@
      outmenus: [],
      backmenus: [],
      appbackmenus: [],
      btnmenus: [],
      appbtnmenus: [],
      unablemenus: [],
      loading: true
    })
@@ -280,6 +287,7 @@
                })
              } else {
                this.sqlmap = new Map()
                this.btnmap = new Map()
                
                let errlist = sessionStorage.getItem('syscheck_app')
                errlist = errlist ? JSON.parse(errlist) : null
@@ -330,7 +338,7 @@
  }
  getMenuParam = (menus) => {
    const { lackmenus, outmenus, unablemenus, backmenus, appbackmenus, stop } = this.state
    const { lackmenus, outmenus, unablemenus, backmenus, appbackmenus, btnmenus, appbtnmenus, stop } = this.state
    let menu = menus.shift()
@@ -339,10 +347,15 @@
      MenuID: menu.MenuID
    }
    let appType = 'pc'
    if (menu.kei_no) {
      param.TypeCharOne = menu.kei_no
      param.typename = menu.typename
      param.lang = menu.lang
      if (['pad', 'mob'].includes(menu.typename)) {
        appType = 'mob'
      }
    }
    this.setState({
@@ -371,26 +384,55 @@
        } else if (!config.enabled) {
          this.setState({unablemenus: [...unablemenus, menu]})
        } else {
          let sqls = getAllSqls(config)
          let keys = sqls.map(item => item.uuid)
          let sqls = []
          let btns = []
          if (keys.length > Array.from(new Set(keys)).length) {
            this.setState({backmenus: [...backmenus, menu]})
          } else {
            let repeat = false
            let premenu = null
            sqls.forEach(item => {
              if (this.sqlmap.has(item.uuid)) {
                window.mkInfo(item)
                if (repeat) return
                repeat = true
                premenu = this.sqlmap.get(item.uuid)
              } else {
                this.sqlmap.set(item.uuid, menu)
          this.getAllSqls(config, appType, sqls, btns)
          if (sqls.length) {
            let keys = sqls.map(item => item.uuid)
            if (keys.length > Array.from(new Set(keys)).length) {
              this.setState({backmenus: [...backmenus, menu]})
            } else {
              let repeat = false
              let premenu = null
              sqls.forEach(item => {
                if (this.sqlmap.has(item.uuid)) {
                  window.mkInfo(item)
                  if (repeat) return
                  repeat = true
                  premenu = this.sqlmap.get(item.uuid)
                } else {
                  this.sqlmap.set(item.uuid, menu)
                }
              })
              if (premenu) {
                this.setState({appbackmenus: [...appbackmenus, [premenu, menu]]})
              }
            })
            if (premenu) {
              this.setState({appbackmenus: [...appbackmenus, [premenu, menu]]})
            }
          }
          if (btns.length) {
            let keys = btns.map(item => item.uuid)
            if (keys.length > Array.from(new Set(keys)).length) {
              this.setState({btnmenus: [...btnmenus, menu]})
            } else {
              let repeat = false
              let premenu = null
              btns.forEach(item => {
                if (this.btnmap.has(item.uuid)) {
                  window.mkInfo(item)
                  if (repeat) return
                  repeat = true
                  premenu = this.btnmap.get(item.uuid)
                } else {
                  this.btnmap.set(item.uuid, menu)
                }
              })
              if (premenu) {
                this.setState({appbtnmenus: [...appbtnmenus, [premenu, menu]]})
              }
            }
          }
        }
@@ -419,8 +461,272 @@
    })
  }
  getAllSqls = (config, appType, sqls, btns) => {
    let filterComponent = (components, label = '') => {
      components.forEach(item => {
        item.$menuname = (config.MenuName || '') + label + '-' + (item.name || '')
        if (item.type === 'tabs') {
          item.subtabs.forEach(tab => {
            filterComponent(tab.components, label)
          })
        } else if (item.type === 'group') {
          filterComponent(item.components, label)
        } else {
          if (item.wrap && item.setting) {
            if (item.wrap.datatype === 'public' || item.wrap.datatype === 'static') {
              item.setting.interType = 'other'
            }
          }
          if (appType === 'mob' && item.type !== 'search' && item.type !== 'topbar' && item.search && item.search.length > 0) {
            item.search = []
          }
          if (appType !== 'mob' && item.search && item.search.length > 0) {
            item.search.forEach(cell => {
              if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(cell.type) && cell.resourceType === '1' && cell.dataSource) {
                sqls.push({uuid: md5(item.uuid + cell.uuid), type: 'sForm', LText: `${item.$menuname}-${cell.label}(搜索)`})
              }
            })
          }
          if (item.subtype === 'tablecard') { // 兼容
            item.type = 'card'
          }
          if (item.setting && item.setting.interType === 'system') {
            item.setting.$name = item.$menuname || ''
            sqls.push({uuid: item.uuid, type: 'datasource', LText: item.setting.$name})
          }
          item.action && item.action.forEach(cell => {
            cell.logLabel = item.$menuname + '-' + cell.label
            btns.push({uuid: cell.uuid, label: cell.logLabel})
            if (cell.hidden === 'true') return false
            resetButton(item, cell)
          })
          if (item.type === 'table') {
            let getCols = (cols) => {
              cols.forEach(col => {
                if (col.type === 'action') {
                  col.type = 'custom'
                }
                if (col.type === 'colspan') {
                  getCols(col.subcols || [])
                } else if (col.type === 'custom') {
                  col.elements.forEach(cell => {
                    if (cell.eleType !== 'button') return
                    cell.logLabel = item.$menuname + '-' + cell.label
                    btns.push({uuid: cell.uuid, label: cell.logLabel})
                    if (cell.hidden === 'true') return
                    resetButton(item, cell)
                  })
                } else if (item.subtype === 'editable' && col.editable === 'true') {
                  if (col.editType === 'select' && col.resourceType === '1') {
                    sqls.push({uuid: col.uuid, type: 'tbForm', LText: `${item.$menuname}-${col.label}(列表单)`})
                  } else if (col.editType === 'popSelect') {
                    if (col.pops) {
                      col.pops.forEach(n => {
                        sqls.push({uuid: n.uuid, type: 'popSource', LText: `${item.$menuname}-${col.label}(列表单)`})
                      })
                    } else {
                      sqls.push({uuid: col.uuid, type: 'popSource', LText: `${item.$menuname}-${col.label}(列表单)`})
                    }
                  }
                }
              })
            }
            getCols(item.cols)
            if (item.subtype === 'editable' && item.submit.intertype === 'system') {
              item.submit.logLabel = item.$menuname + '-提交'
              sqls.push({uuid: 'submit_' + item.uuid, type: 'editable', LText: item.submit.logLabel})
            }
          } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
            item.subcards && item.subcards.forEach(card => {
              card.elements && card.elements.forEach(cell => {
                if (cell.eleType !== 'button') return
                cell.logLabel = item.$menuname + '-' + cell.label
                btns.push({uuid: cell.uuid, label: cell.logLabel})
                if (cell.hidden === 'true') return
                resetButton(item, cell)
              })
              if (!card.backElements || card.backElements.length === 0) return
              card.backElements.forEach(cell => {
                if (cell.eleType !== 'button') return
                cell.logLabel = item.$menuname + '-' + cell.label
                btns.push({uuid: cell.uuid, label: cell.logLabel})
                if (cell.hidden === 'true') return
                resetButton(item, cell)
              })
            })
          } else if (item.type === 'balcony') {
            item.elements.forEach(cell => {
              if (cell.eleType !== 'button') return
              cell.logLabel = item.$menuname + '-' + cell.label
              btns.push({uuid: cell.uuid, label: cell.logLabel})
              if (cell.hidden === 'true') return
              resetButton(item, cell)
            })
          } else if (item.type === 'form') {
            item.subcards.forEach(group => {
              group.subButton.OpenType = 'formSubmit'
              group.subButton.uuid = group.uuid
              group.subButton.modal = {
                fields: group.fields
              }
              group.subButton.logLabel = item.$menuname + '-' + group.subButton.label
              btns.push({uuid: group.uuid, label: group.subButton.logLabel})
              resetButton(item, group.subButton)
            })
          } else if (item.type === 'module' && item.subtype === 'invoice') {
            if (item.buyer.setting && item.buyer.setting.interType === 'system') {
              sqls.push({uuid: item.uuid + 'buyer', type: 'datasource', LText: item.$menuname + '-buyer'})
            }
            if (item.detail.setting && item.detail.setting.interType === 'system') {
              sqls.push({uuid: item.uuid + 'detail', type: 'datasource', LText: item.$menuname + '-detail'})
            }
            sqls.push({uuid: item.uuid + item.billSaveBtn.type, type: 'button', LText: item.$menuname + '-' + item.billSaveBtn.label})
            sqls.push({uuid: item.uuid + item.billOutBtn.type, type: 'button', LText: item.$menuname + '-' + item.billOutBtn.label})
            sqls.push({uuid: item.uuid + 'billback', type: 'btnCallBack', LText: item.$menuname + '-'  + item.billOutBtn.label + '(回调)'})
          }
        }
      })
    }
    let resetButton = (item, cell) => {
      if (['exec', 'prompt', 'pop', 'form', 'formSubmit'].includes(cell.OpenType)) {
        if (cell.intertype === 'system' || cell.procMode === 'system') { // 系统接口
          sqls.push({uuid: cell.uuid, type: 'button', LText: cell.logLabel})
        }
        if (cell.callbackType === 'script' && cell.verify && cell.verify.cbScripts) {
          sqls.push({uuid: 'back_' + cell.uuid, type: 'btnCallBack', LText: cell.logLabel})
        }
        if (['pop', 'formSubmit'].includes(cell.OpenType) && cell.modal && cell.modal.fields) {
          cell.modal.fields.forEach(form => {
            // 数据源sql语句,预处理,权限黑名单字段设置为隐藏表单
            if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(form.type) && form.resourceType === '1') {
              sqls.push({uuid: md5(cell.uuid + form.uuid), type: 'form', LText: `${cell.logLabel}-${form.label}(表单)`})
            } else if (form.type === 'popSelect') {
              sqls.push({uuid: md5(cell.uuid + form.uuid), type: 'popSource', LText: `${cell.logLabel}-${form.label}(表单)`})
            }
          })
        }
      } else if (cell.OpenType === 'excelIn') {
        if (cell.intertype === 'system') {
          sqls.push({uuid: cell.uuid, type: 'excelIn', LText: cell.logLabel})
        }
      } else if (cell.OpenType === 'excelOut') {
        if (cell.intertype === 'system' && cell.verify && cell.verify.dataType === 'custom') {
          sqls.push({uuid: cell.uuid, type: 'excelOut', LText: cell.logLabel || ''})
        } else if (cell.intertype === 'system' && cell.verify && item.setting && item.setting.interType === 'system') {
          if (appType === 'mob') {
            cell.pagination = 'false'
          }
          if (item.subtype === 'dualdatacard' || item.setting.laypage !== cell.pagination) {
            sqls.push({uuid: cell.uuid, type: 'excelOut', LText: cell.logLabel || ''})
          }
        }
      } else if (cell.OpenType === 'funcbutton') {
        if (cell.funcType === 'print') {
          if (cell.intertype === 'system' && cell.verify && cell.verify.dataType === 'custom') {
            sqls.push({uuid: cell.uuid, type: 'print', LText: cell.logLabel || ''})
          }
          if (cell.execMode === 'pop' && cell.modal && cell.modal.fields) {
            cell.modal.fields.forEach(form => {
              // 数据源sql语句,预处理,权限黑名单字段设置为隐藏表单
              if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(form.type) && form.resourceType === '1') {
                sqls.push({uuid: md5(cell.uuid + form.uuid), type: 'form', LText: `${cell.logLabel}-${form.label}(表单)`})
              } else if (form.type === 'popSelect') {
                sqls.push({uuid: md5(cell.uuid + form.uuid), type: 'popSource', LText: `${cell.logLabel}-${form.label}(表单)`})
              }
            })
          }
        } else if ((cell.funcType === 'refund' || cell.funcType === 'pay') && cell.payMode === 'system') {
          sqls.push({uuid: cell.uuid, type: 'pay', LText: cell.logLabel})
        }
      } else if (cell.OpenType === 'innerpage' || cell.OpenType === 'outerpage') {
        if (cell.pageTemplate === 'pay' && cell.payMode === 'system') {
          sqls.push({uuid: cell.uuid, type: 'pay', LText: cell.logLabel})
        }
      } else if (cell.OpenType === 'popview') {
        if (cell.config && cell.config.components && cell.config.enabled) {
          let label = (item.name ? '-' + item.name : '') + '-' + cell.label
          filterComponent(cell.config.components, label, true)
        }
      }
    }
    if (appType === 'mob') {
      config.components.forEach(item => {
        if (item.type === 'topbar' && item.wrap.type !== 'navbar' && item.search) {
          let search = []
          search.push(...item.search.fields)
          item.search.groups.forEach(group => {
            search.push(...group.fields)
          })
          if (search.length > 0) {
            search.forEach(cell => {
              if (['select', 'link', 'multiselect', 'checkcard', 'radio'].includes(cell.type) && cell.resourceType === '1' && cell.dataSource) {
                sqls.push({uuid: cell.uuid, type: 'sForm', LText: `搜索栏-${cell.label}(表单)`})
              }
            })
          }
        }
      })
    }
    if (config.interfaces && config.interfaces.length > 0) {
      config.interfaces.forEach(m => {
        if (m.status !== 'true' || m.setting.interType !== 'system') return false
        m.setting.$name = (config.MenuName || '') + '-' + (m.name || '')
        sqls.push({uuid: m.uuid, type: 'interface', LText: m.setting.$name})
      })
    }
    filterComponent(config.components)
  }
  record = (type) => {
    const { lackmenus, outmenus, unablemenus, backmenus, appbackmenus } = this.state
    const { lackmenus, outmenus, unablemenus, backmenus, appbackmenus, btnmenus, appbtnmenus } = this.state
    let menus = []
@@ -437,6 +743,13 @@
      menus.push(item.MenuID)
    })
    appbackmenus.forEach(item => {
      menus.push(item[0].MenuID)
      menus.push(item[1].MenuID)
    })
    btnmenus.forEach(item => {
      menus.push(item.MenuID)
    })
    appbtnmenus.forEach(item => {
      menus.push(item[0].MenuID)
      menus.push(item[1].MenuID)
    })
@@ -459,7 +772,7 @@
  }
  render () {
    const { loading, activeMenu, menulist, remain, lackmenus, outmenus, unablemenus, backmenus, appbackmenus } = this.state
    const { loading, activeMenu, menulist, remain, lackmenus, outmenus, unablemenus, backmenus, appbackmenus, btnmenus, appbtnmenus } = this.state
    if (!sessionStorage.getItem('UserID')) return null
@@ -504,6 +817,18 @@
              return <div key={i}>{item[0].MenuName} <span></span> {item[0].pName} <SwapOutlined /> {item[1].MenuName} <span></span> {item[1].pName}</div>
            })}
          </div> : null}
          {btnmenus.length ? <div className="item-wrap">
            <div className="title">菜单按钮ID重复</div>
            {btnmenus.map((item, i) => {
              return <div key={i}>{item.MenuName} <span></span> {item.pName}</div>
            })}
          </div> : null}
          {appbtnmenus.length ? <div className="item-wrap">
            <div className="title">菜单按钮ID重复(菜单间)</div>
            {appbtnmenus.map((item, i) => {
              return <div key={i}>{item[0].MenuName} <span></span> {item[0].pName} <SwapOutlined /> {item[1].MenuName} <span></span> {item[1].pName}</div>
            })}
          </div> : null}
        </div>
      </div>
    )