king
2025-01-16 d5ed6bd23455c63b5de88f8740c7325658f5241e
src/utils/utils-custom.js
@@ -451,11 +451,7 @@
            card.elements = card.elements.map(cell => {
              if (cell.eleType === 'button') {
                cell.uuid = md5(commonId + cell.uuid)
                if (clear && cell.pageTemplate === 'linkpage' && cell.linkmenu) {
                  cell.pageTemplate = ''
                  cell.linkmenu = ''
                }
                this.resetBtn(cell, commonId)
                this.resetBtn(cell, commonId, clear)
              } else {
                cell.uuid = this.getuuid()
              }
@@ -467,11 +463,7 @@
            card.backElements = card.backElements.map(cell => {
              if (cell.eleType === 'button') {
                cell.uuid = md5(commonId + cell.uuid)
                if (clear && cell.pageTemplate === 'linkpage' && cell.linkmenu) {
                  cell.pageTemplate = ''
                  cell.linkmenu = ''
                }
                this.resetBtn(cell, commonId)
                this.resetBtn(cell, commonId, clear)
              } else {
                cell.uuid = this.getuuid()
              }
@@ -491,11 +483,7 @@
          item.elements = item.elements.map(cell => {
            if (cell.eleType === 'button') {
              cell.uuid = md5(commonId + cell.uuid)
              if (clear && cell.pageTemplate === 'linkpage' && cell.linkmenu) {
                cell.pageTemplate = ''
                cell.linkmenu = ''
              }
              this.resetBtn(cell, commonId)
              this.resetBtn(cell, commonId, clear)
            } else {
              cell.uuid = this.getuuid()
            }
@@ -528,12 +516,7 @@
                cell.uuid = md5(commonId + cell.uuid)
                if (cell.eleType === 'button') {
                  if (clear && cell.pageTemplate === 'linkpage' && cell.linkmenu) {
                    cell.pageTemplate = ''
                    cell.linkmenu = ''
                  }
                  this.resetBtn(cell, commonId)
                  this.resetBtn(cell, commonId, clear)
                }
                return cell
@@ -572,11 +555,15 @@
          })
          if (cell.subButton) {
            this.resetBtn(cell.subButton, commonId)
            this.resetBtn(cell.subButton, commonId, clear)
          }
          return cell
        })
      } else if (item.type === 'login') {
        if (clear) {
          item.wrap.linkmenu = ''
        }
      }
  
      if (item.btnlog) {
@@ -587,12 +574,7 @@
        item.action = item.action.map(cell => {
          cell.uuid = md5(commonId + cell.uuid)
          if (clear && cell.pageTemplate === 'linkpage' && cell.linkmenu) {
            cell.pageTemplate = ''
            cell.linkmenu = ''
          }
          this.resetBtn(cell, commonId)
          this.resetBtn(cell, commonId, clear)
          return cell
        })
@@ -650,15 +632,25 @@
  /**
   * @description 按钮重置
   */
  static resetBtn (btn, commonId) {
  static resetBtn (btn, commonId, clear = false) {
    if (btn.OpenType === 'pop' || (btn.OpenType === 'funcbutton' && btn.execMode === 'pop')) {
      if (btn.modal && btn.modal.fields.length > 0) {
      if (btn.modal && btn.modal.fields && btn.modal.fields.length > 0) {
        btn.modal.fields = btn.modal.fields.map(m => {
          m.uuid = this.getuuid()
          return m
        })
      }
    }
    if (clear) {
      if (btn.pageTemplate === 'linkpage') {
        btn.pageTemplate = ''
      }
      delete btn.linkmenu
      delete btn.openmenu
      delete btn.refreshTab
    }
    if (btn.switchTab && btn.switchTab.length > 0) {
      btn.switchTab = btn.switchTab.map(m => md5(commonId + m))
    }
@@ -666,6 +658,15 @@
      btn.anchors = btn.anchors.map(m => md5(commonId + m))
    }
    if (btn.syncComponent && btn.syncComponent[0] === 'multiComponent' && btn.syncComponents) {
      if (btn.syncComponents[0] && Array.isArray(btn.syncComponents[0])) {
        btn.syncComponents = btn.syncComponents.map((item, i) => {
          return {
            syncComId: item,
            label: '',
            uuid: 'fixed' + i
          }
        })
      }
      btn.syncComponents = btn.syncComponents.map(m => {
        m.syncComId = m.syncComId.map(n => {
          if (/\$focus/.test(n)) {
@@ -684,6 +685,10 @@
        return md5(commonId + m)
      })
    }
    if (btn.OpenType === 'popview' && btn.config && btn.config.components) {
      btn.config.components = this.resetConfig(btn.config.components, commonId)
    }
  }
@@ -771,14 +776,7 @@
            if (cell.eleType === 'button') {
              cell.uuid = md5(commonId + cell.uuid)
              if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
                if (cell.modal && cell.modal.fields.length > 0) {
                  cell.modal.fields = cell.modal.fields.map(m => {
                    m.uuid = this.getuuid()
                    return m
                  })
                }
              }
              this.resetBtn(cell, commonId)
            } else {
              cell.uuid = this.getuuid()
            }
@@ -792,14 +790,8 @@
          card.backElements = card.backElements.map(cell => {
            if (cell.eleType === 'button') {
              cell.uuid = md5(commonId + cell.uuid)
              if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
                if (cell.modal && cell.modal.fields.length > 0) {
                  cell.modal.fields = cell.modal.fields.map(m => {
                    m.uuid = this.getuuid()
                    return m
                  })
                }
              }
              this.resetBtn(cell, commonId)
            } else {
              cell.uuid = this.getuuid()
            }
@@ -818,14 +810,8 @@
        item.elements = item.elements.map(cell => {
          if (cell.eleType === 'button') {
            cell.uuid = md5(commonId + cell.uuid)
            if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
              if (cell.modal && cell.modal.fields.length > 0) {
                cell.modal.fields = cell.modal.fields.map(m => {
                  m.uuid = this.getuuid()
                  return m
                })
              }
            }
            this.resetBtn(cell, commonId)
          } else {
            cell.uuid = this.getuuid()
          }
@@ -850,14 +836,7 @@
            col.elements = col.elements.map(cell => {
              cell.uuid = md5(commonId + cell.uuid)
              if (cell.eleType === 'button') {
                if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
                  if (cell.modal && cell.modal.fields.length > 0) {
                    cell.modal.fields = cell.modal.fields.map(m => {
                      m.uuid = this.getuuid()
                      return m
                    })
                  }
                }
                this.resetBtn(cell, commonId)
              }
              return cell
            })
@@ -902,14 +881,7 @@
      }
      item.action = item.action.map(cell => {
        cell.uuid = md5(commonId + cell.uuid)
        if (cell.OpenType === 'pop' || (cell.OpenType === 'funcbutton' && cell.execMode === 'pop')) {
          if (cell.modal && cell.modal.fields.length > 0) {
            cell.modal.fields = cell.modal.fields.map(m => {
              m.uuid = this.getuuid()
              return m
            })
          }
        }
        this.resetBtn(cell, commonId)
        return cell
      })
@@ -1963,6 +1935,10 @@
          })
        }
        let emptys = []
        if (cell.Ot !== 'notRequired') {
          forms.push(...columns)
        }
        cell.verify.uniques.forEach(m => {
          if (m.status === 'false') return
@@ -1974,21 +1950,25 @@
        })
        if (emptys.length) {
          errors.push({ level: 0, detail: `按钮“${cell.label}”唯一性验证字段${emptys.join('、')},在表单中不存在!`})
          if (cell.Ot === 'notRequired') {
            errors.push({ level: 0, detail: `按钮“${cell.label}”唯一性验证字段${emptys.join('、')},在表单中不存在!`})
          } else {
            errors.push({ level: 0, detail: `按钮“${cell.label}”唯一性验证字段${emptys.join('、')},在表单与字段集中不存在!`})
          }
        }
      }
      if (cell.OpenType === 'form' && cell.formType === 'count_line') return
     
      if (cell.intertype === 'system') {
        if (cell.Ot === 'notRequired' && cell.verify && cell.verify.voucher && cell.verify.voucher.enabled) {
          errors.push({ level: 0, detail: `按钮“${cell.label}”使用了创建凭证函数,需要选择行!`})
        }
        // if (cell.Ot === 'notRequired' && cell.verify && cell.verify.voucher && cell.verify.voucher.enabled) {
        //   errors.push({ level: 0, detail: `按钮“${cell.label}”使用了创建凭证函数,需要选择行!`})
        // }
      } else if (cell.intertype === 'custom' || cell.intertype === 'outer') {
        if (cell.callbackType === 'script' && (!cell.verify || !cell.verify.cbScripts || cell.verify.cbScripts.filter(item => item.status !== 'false').length === 0)) {
          errors.push({ level: 0, detail: `按钮“${cell.label}”使用了自定义脚本回调,回调脚本不可为空!`})
        } else if (cell.procMode === 'system' && cell.Ot === 'notRequired' && cell.verify && cell.verify.voucher && cell.verify.voucher.enabled) {
          errors.push({ level: 0, detail: `按钮“${cell.label}”使用了创建凭证函数,需要选择行!`})
        // } else if (cell.procMode === 'system' && cell.Ot === 'notRequired' && cell.verify && cell.verify.voucher && cell.verify.voucher.enabled) {
        //   errors.push({ level: 0, detail: `按钮“${cell.label}”使用了创建凭证函数,需要选择行!`})
        }
      }
    } else if (cell.OpenType === 'funcbutton') {
@@ -3084,11 +3064,18 @@
GOTO_RETURN:
  ROLLBACK TRAN`
  let filterComponent = (components, mainSearch, label = '') => {
  let filterComponent = (components, mainSearch, label = '', ispop) => {
    components.forEach(item => {
      item.$menuname = (config.MenuName || '') + label + '-' + (item.name || '')
      if (item.type === 'tabs') {
        if (config.Template === 'BaseTable') {
          item.subtabs.forEach(tab => {
            if (tab.permission !== 'true' && tab.components[0] && tab.components[0].wrap) {
              tab.components[0].wrap.permission = 'false'
            }
          })
        }
        item.subtabs.forEach(tab => {
          let _mainSearch = mainSearch || []
@@ -3099,10 +3086,11 @@
              _mainSearch = com.search || []
            })
          }
          filterComponent(tab.components, _mainSearch, label)
          filterComponent(tab.components, _mainSearch, label, ispop)
        })
      } else if (item.type === 'group') {
        filterComponent(item.components, mainSearch, label)
        filterComponent(item.components, mainSearch, label, ispop)
      } else {
        if (item.wrap && item.setting) {
          if (item.wrap.datatype === 'public' || item.wrap.datatype === 'static') {
@@ -3140,6 +3128,8 @@
            roleId = ''
          } else if (item.setting.database === 'sso') {
            roleId = ''
          } else if (ispop) {
            roleId = ''
          }
          sqls.push({uuid: item.uuid, roleId: roleId, type: 'datasource', ...msg})
@@ -3154,7 +3144,7 @@
        item.action && item.action.forEach(cell => {
          if (cell.hidden === 'true') return false
          
          resetButton(item, cell)
          resetButton(item, cell, false, ispop)
        })
        if (item.type === 'table') {
@@ -3169,7 +3159,7 @@
                col.elements.forEach(cell => {
                  if (cell.eleType !== 'button' || cell.hidden === 'true') return
                  
                  resetButton(item, cell)
                  resetButton(item, cell, false, ispop)
                })
              } else if (item.subtype === 'editable' && col.editable === 'true') {
                if (col.editType === 'select' && col.resourceType === '1') {
@@ -3206,7 +3196,7 @@
            card.elements && card.elements.forEach(cell => {
              if (cell.eleType !== 'button' || cell.hidden === 'true') return
              
              resetButton(item, cell)
              resetButton(item, cell, false, ispop)
            })
  
            if (!card.backElements || card.backElements.length === 0) return
@@ -3214,14 +3204,14 @@
            card.backElements.forEach(cell => {
              if (cell.eleType !== 'button' || cell.hidden === 'true') return
              
              resetButton(item, cell, true)
              resetButton(item, cell, true, ispop)
            })
          })
        } else if (item.type === 'balcony') {
          item.elements.forEach(cell => {
            if (cell.eleType !== 'button' || cell.hidden === 'true') return
            
            resetButton(item, cell)
            resetButton(item, cell, false, ispop)
          })
        } else if (item.type === 'form') {
          item.subcards.forEach(group => {
@@ -3234,7 +3224,7 @@
              fields: group.fields
            }
            resetButton(item, group.subButton)
            resetButton(item, group.subButton, false, ispop)
          })
        } else if (item.type === 'module' && item.subtype === 'invoice') {
          if (item.buyer.setting && item.buyer.setting.interType === 'system') {
@@ -3265,7 +3255,7 @@
    })
  }
  let resetButton = (item, cell, isback) => {
  let resetButton = (item, cell, isback, ispop) => {
    cell.logLabel = item.$menuname + '-' + cell.label
    let roleId = cell.uuid
    if (item.wrap && item.wrap.permission === 'false') {
@@ -3273,6 +3263,8 @@
    } else if (cell.hidden === 'true' || cell.permission === 'false') {
      roleId = ''
    } else if (cell.database === 'sso') {
      roleId = ''
    } else if (ispop) {
      roleId = ''
    }
@@ -3319,7 +3311,7 @@
          } else if (form.type === 'popSelect') {
            let msg = getPopSelectSql(form)
        
            sqls.push({uuid: form.uuid, type: 'popSource', ...msg})
            sqls.push({uuid: md5(cell.uuid + form.uuid), type: 'popSource', ...msg})
          }
        })
      }
@@ -3362,7 +3354,7 @@
            } else if (form.type === 'popSelect') {
              let msg = getPopSelectSql(form)
          
              sqls.push({uuid: form.uuid, type: 'popSource', ...msg})
              sqls.push({uuid: md5(cell.uuid + form.uuid), type: 'popSource', ...msg})
            }
          })
        }
@@ -3402,7 +3394,9 @@
          })
        }
        filterComponent(cell.config.components, _mainSearch, '-' + cell.label)
        let label = (item.name ? '-' + item.name : '') + '-' + cell.label
        filterComponent(cell.config.components, _mainSearch, label, true)
      }
    }
  }
@@ -3753,22 +3747,21 @@
    if (formdata && verify.billcodes && verify.billcodes.length > 0) {
      verify.billcodes.forEach(item => {
        let _key = item.field.toLowerCase()
        let _linkKey = item.linkField ? item.linkField.toLowerCase() : ''
  
        if (!formkeys.includes(_key)) return // 表单中不含单号生成字段
  
        let _lpline = ''
        if (item.TypeCharOne === 'Lp') {
          if (_linkKey === 'bid' && BID) { // 替换bid
          if (/^BID$/ig.test(item.linkField)) {
            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@BID@,48)`
          } else {
            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${_linkKey},48)`
            _lpline = `set @ModularDetailCode= 'Lp'+ right('${item.mark || btn.uuid}'+@${item.linkField},48)`
          }
        } else if (item.TypeCharOne === 'BN') {
          if (_linkKey === 'bid' && BID) { // 替换bid
          if (/^BID$/ig.test(item.linkField)) {
            _lpline = `set @ModularDetailCode= 'BN'+ right(@BID@,48)`
          } else {
            _lpline = `set @ModularDetailCode= 'BN'+ right(@${_linkKey},48)`
            _lpline = `set @ModularDetailCode= 'BN'+ right(@${item.linkField},48)`
          }
        } else {
          _lpline = `set @ModularDetailCode= right('${item.ModularDetailCode}',50)`
@@ -3811,24 +3804,26 @@
          let _val2 = ''
  
          arr.push(_key)
          if (_key === 'bid') { // 表单中没有bid则使用系统bid变量
          if (_key === 'bid') {
            _val = BID
          } else {
            _val = `'@mk_${_key}_mk@'`
            // _val = `'@mk_${_key}_mk@'`
            _val = `@${_field}`
          }
          _fieldValue.push(`${_key}=${_val}`)
          if (_key === 'bid') { // 表单中没有bid则使用系统bid变量
          if (_key === 'bid') {
            _val2 = `' + ${BID} + '`
          } else {
            _val2 = `@mk_${_key}_mk@`
            // _val2 = `@mk_${_key}_mk@`
            _val2 = `' + @${_field} + '`
          }
          _value.push(`${_labels[index] || ''}:${_val2}`)
        })
  
        if (!arr.includes(primaryKey.toLowerCase())) {
        if (!arr.includes(primaryKey.toLowerCase()) && btn.Ot !== 'notRequired') {
          _fieldValue.push(`${primaryKey} !=${primaryId}`)
        }
  
@@ -3879,15 +3874,20 @@
    let hasvoucher = false
  
    // 凭证-显示列中选取,必须选行
    if (verify.voucher && verify.voucher.enabled && btn.Ot !== 'requiredOnce') {
    if (verify.voucher && verify.voucher.enabled) {
      let _voucher = verify.voucher
      let linkField = `@${_voucher.linkField}`
      if (/^BID$/ig.test(_voucher.linkField)) {
        linkField = BID
      }
  
      hasvoucher = true
  
      _sql += `
        /* 创建凭证 */
        exec s_BVoucher_Create
          @Bill ='0',
          @Bill = ${linkField},
          @BVoucherType ='${_voucher.BVoucherType}',
          @VoucherTypeOne ='${_voucher.VoucherTypeOne}',
          @VoucherTypeTwo ='${_voucher.VoucherTypeTwo}',
@@ -4082,7 +4082,9 @@
        _sql += `
          /* 工作流异常sql */
          if @works_flow_error@ != ''
          select @ErrorCode='E',@retmsg=@works_flow_error@ goto aaa
          begin
            select @ErrorCode='E',@retmsg=@works_flow_error@ goto aaa
          end
          /* 工作流默认sql */
          insert into s_my_works_flow (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,work_group,works_flow_detail_id,work_grade,bid,createuserid,CreateUser,CreateStaff,upid)
@@ -4101,7 +4103,9 @@
        _sql += `
          /* 工作流异常sql */
          if @works_flow_error@ != ''
          select @ErrorCode='E',@retmsg=@works_flow_error@ goto aaa
          begin
            select @ErrorCode='E',@retmsg=@works_flow_error@ goto aaa
          end
          if @works_flow_countersign@ = 'Y'
          begin
@@ -4695,7 +4699,7 @@
        } else if (['mk_address'].includes(s)) {
          decSql.push(`@mk_address nvarchar(100)`)
        } else if (['mk_deleted'].includes(s)) {
          secSql.push(`@mk_deleted int`)
          decSql.push(`@mk_deleted int`)
        } else {
          decSql.push(`@${s} nvarchar(50)`)
        }
@@ -4890,7 +4894,7 @@
    let DateCount = ''
    if (_dataresource) {
      /*system_query*/
      if (/@pageSize@|@orderBy@|@mk_total/i.test(testSql)) {
      if (/@pageSize@|@orderBy@|@mk_total/i.test(testSql) || (item.wrap && item.wrap.tree === 'true')) {
        LText = `select ${arr_field} from ${_dataresource} ${_search} `
      } else if (item.setting.laypage === 'true' && item.setting.order) {
        LText = `select top @pageSize@ ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by @orderBy@) as rows from ${_dataresource} ${_search}) tmptable where rows > @pageSize@ * (@pageIndex@ - 1) order by tmptable.rows `
@@ -5233,7 +5237,9 @@
        sql += `
        /* 工作流异常sql */
        if @works_flow_error@ != ''
        select @ErrorCode='E',@retmsg=@works_flow_error@ goto aaa
        begin
          select @ErrorCode='E',@retmsg=@works_flow_error@ goto aaa
        end
        /* 工作流默认sql */
        insert into s_my_works_flow (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,work_group,works_flow_detail_id,work_grade,bid,createuserid,CreateUser,CreateStaff,upid)
@@ -6438,5 +6444,32 @@
  filterComponent(config.components, _mainSearch)
  let keys = sqls.map(item => item.uuid)
  if (keys.length > Array.from(new Set(keys)).length) {
    if (window.backend) {
      let m = new Map()
      let n = new Map()
      sqls.forEach(item => {
        if (m.has(item.uuid)) {
          if (!n.has(item.uuid)) {
            window.mkInfo(m.get(item.uuid))
            n.set(item.uuid, true)
          }
          window.mkInfo(item)
        } else {
          m.set(item.uuid, item)
        }
      })
      notification.warning({
        top: 92,
        message: '存在重复的后端脚本ID!',
        duration: 5
      })
    }
    return []
  }
  return sqls
}