king
2025-05-08 400fee62fb40006a9839f1c3a8244b82566b5057
src/templates/sharecomponent/searchcomponent/index.jsx
@@ -61,6 +61,18 @@
      }, () => {
        this.handleSearch(item)
      })
    } else if (type === 'replace') {
      delete item.focus
      this.setState({
        searchlist: searchlist.map(cell => {
          if (cell.field && cell.field.toLowerCase() === item.field.toLowerCase()) {
            return item
          }
          return cell
        }),
      }, () => {
        this.handleSearch(item)
      })
    } else if (type === 'multil') {
      let list = [...searchlist, ...item]
      list = list.filter(item => !item.origin) // 去除系统项
@@ -93,6 +105,7 @@
   * @description 搜索条件编辑,获取搜索条件表单信息
   */
  handleSearch = (card) => {
    const { config } = this.props
    const { searchlist } = this.state
    let linkableFields = []
@@ -108,8 +121,8 @@
    })
    let columns = null
    if (this.props.config.type === 'table') {
      columns = this.props.config.columns.map(item => {
    if (config.columns && config.columns.length) {
      columns = config.columns.map(item => {
        return {key: item.uuid, text: item.field, value: item.field, label: item.label}
      })
    }
@@ -204,20 +217,16 @@
        return
      }
      if (['checkcard', 'select', 'multiselect', 'link'].includes(res.type) && res.resourceType === '1' && /\s/.test(res.dataSource)) {
      if (['checkcard', 'select', 'multiselect', 'link'].includes(res.type) && res.resourceType === '1' && res.database !== 'sso' && /\s/.test(res.dataSource)) {
        this.setState({
          sqlVerifing: true
        })
        let sql = res.dataSource
        let sql = `declare @mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20)
        ${res.dataSource}`
        sql = sql.replace(/@\$|\$@/ig, '')
        let rduri = ''
        if (window.GLOB.mainSystemApi && res.database === 'sso') {
          rduri = window.GLOB.mainSystemApi
        }
        
        Api.sDebug(sql, rduri).then(result => {
        Api.sDebug(sql).then(result => {
          if (result.status || result.ErrCode === '-2') {
            this.setState({
              sqlVerifing: false,
@@ -250,19 +259,19 @@
   */
  deleteElement = (card) => {
    const { config } = this.props
    let _this = this
    let that = this
    confirm({
      content: `确定删除 - ${card.label} ?`,
      onOk() {
        let _searchlist = fromJS(_this.state.searchlist).toJS()
        let _searchlist = fromJS(that.state.searchlist).toJS()
        _searchlist = _searchlist.filter(item => item.uuid !== card.uuid)
        _this.setState({
        that.setState({
          searchlist: _searchlist
        }, () => {
          _this.props.updatesearch({...config, search: _searchlist})
          that.props.updatesearch({...config, search: _searchlist})
        })
      },
      onCancel() {}
@@ -328,8 +337,13 @@
    const { config } = this.props
    const { searchlist, visible, sqlVerifing, card, showField, setVisible } = this.state
    let size = ''
    if (config.wrap && config.wrap.searchSize) {
      size = ' mk-order-' + config.wrap.searchSize
    }
    return (
      <div className={'model-table-search-list length' + searchlist.length + (showField ? ' show-field' : '')}>
      <div className={'model-table-search-list length' + searchlist.length + (showField ? ' show-field' : '') + size}>
        <FieldsComponent config={{uuid: config.uuid, search: searchlist}} type="search" />
        <Switch className="switch-field-show" checkedChildren="开" unCheckedChildren="关" defaultChecked={showField} onChange={this.onFieldChange} />
        <DragElement
@@ -345,7 +359,7 @@
          title={card && card.copyType === 'search' ?  '搜索条件-复制' : '搜索条件-编辑'}
          wrapClassName="mk-scroll-modal"
          visible={visible}
          width={850}
          width={950}
          maskClosable={false}
          onOk={this.handleSubmit}
          confirmLoading={sqlVerifing}