king
2022-04-29 eec619b6e3339e9999a7a1c2c5454cef5d763b24
src/utils/utils.js
@@ -249,9 +249,9 @@
      item.required = !item.hidden && item.required === 'true'
      item.advanced = item.advanced === 'true'
      item.$forbid = item.query === 'false'
      item.precision = item.precision || 'day'
      if (item.type === 'date') { // 时间搜索
        item.precision = item.precision || 'day'
        let format = 'YYYY-MM-DD'
        if (item.precision === 'day') {
@@ -269,7 +269,6 @@
      } else if (item.type === 'dateweek') {
        item.initval = item.initval ? moment().subtract(item.initval * 7, 'days').format('YYYY-MM-DD') : ''
      } else if (item.type === 'daterange') {
        item.precision = item.precision || 'day'
        let format = 'YYYY-MM-DD'
        if (item.precision === 'day') {
@@ -381,7 +380,7 @@
        label: cell.label,
        value: cell.initval,
        required: cell.required,
        precision: cell.precision || '',
        precision: cell.precision || 'day',
        forbid: cell.$forbid
      }
      
@@ -507,20 +506,23 @@
  static joinMainSearchkey (searches) {
    if (!searches || searches.length === 0) return ''
    let searchText = ''
    let searchText = []
    searches.forEach(item => {
      if (item.forbid || !item.value) return
      
      searchText += (searchText !== '' ? ' AND ' : '')
      if (item.type === 'text' || item.type === 'select') { // 综合搜索,文本或下拉,所有字段拼接
        let str = item.match === '=' ? '' : '%'
        let str = item.match === 'like' || item.match === 'not like' ? '%' : ''
        let fields = item.key.split(',').map(field => {
          return field + ' ' + item.match + ' \'' + str + item.value + str + '\''
        })
        searchText += '(' + fields.join(' OR ') + ')'
        searchText.push('(' + fields.join(' OR ') + ')')
      } else if (item.type === 'checkcard') {
        let str = item.match === 'like' || item.match === 'not like' ? '%' : ''
        searchText.push('(' + item.key + ' ' + item.match + ' \'' + str + item.value + str + '\')')
      } else if (item.type === 'multi') {
        searchText += `'${item.value}' ${item.match} '%'+${item.key}+'%'`
        searchText.push(`('${item.value}' ${item.match} '%'+${item.key}+'%')`)
      } else if (item.type === 'date') {
        let _val = item.value
        let timetail = ''
@@ -544,17 +546,17 @@
          timetail = '.000'
        }
        searchText += '(' + item.key + ' ' + _match + ' \'' + _val + timetail + '\')'
        searchText.push('(' + item.key + ' ' + _match + ' \'' + _val + timetail + '\')')
      } else if (item.type === 'datemonth') { // 月-过滤条件,从月开始至结束,结束时间为月末加一天的0点,方式为<
        let _startval = moment(item.value, 'YYYY-MM').startOf('month').format('YYYY-MM-DD') + ' 00:00:00.000'
        let _endval = moment(item.value, 'YYYY-MM').endOf('month').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000'
        searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')'
        searchText.push('(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')')
      } else if (item.type === 'dateweek') { // 周-过滤条件
        let _startval = moment(item.value, 'YYYY-MM-DD' ).startOf('week').format('YYYY-MM-DD') + ' 00:00:00.000'
        let _endval = moment(item.value, 'YYYY-MM-DD').endOf('week').add(1, 'days').format('YYYY-MM-DD') + ' 00:00:00.000'
        searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')'
        searchText.push('(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')')
      } else if (item.type === 'daterange') {
        let val = item.value.split(',')
        let _startval = ''
@@ -574,17 +576,17 @@
          _endval = val[1] + '.000'
        }
        searchText += '(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')'
        searchText.push('(' + item.key + ' >= \'' + _startval + '\' AND ' + item.key + ' < \'' + _endval + '\')')
      } else if (item.type === 'range') {
        let val = item.value.split(',')
        searchText += '(' + item.key + ' >= \'' + val[0] + '\' AND ' + item.key + ' < \'' + val[1] + '\')'
        searchText.push('(' + item.key + ' >= \'' + val[0] + '\' AND ' + item.key + ' < \'' + val[1] + '\')')
      } else {
        searchText += '(' + item.key + ' ' + item.match + ' \'' + item.value + '\')'
        searchText.push('(' + item.key + ' ' + item.match + ' \'' + item.value + '\')')
      }
    })
    return searchText
    return searchText.join(' AND ')
  }
  /**
@@ -851,7 +853,7 @@
      sql = sql.replace(/@db@/ig, window.GLOB.externalDatabase)
    }
    if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
    if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
      console.info(sql)
    }
@@ -1143,7 +1145,7 @@
      
      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
    if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
    if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
      let fsql = `
      ${_sql}
      ${_sqlInsert}
@@ -1355,7 +1357,7 @@
      
      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
    if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
    if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
      let fsql = `
      ${_sql}
      ${_sqlInsert}
@@ -1569,6 +1571,24 @@
      Declare @tbid nvarchar(50),@ErrorCode nvarchar(50),@retmsg nvarchar(4000),@BillCode nvarchar(50),@BVoucher nvarchar(50),@FIBVoucherDate nvarchar(50), @FiYear nvarchar(50), @UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(50),@mk_organization nvarchar(50),@login_city nvarchar(50),@bid nvarchar(50),@ModularDetailCode nvarchar(50)${_declarefields}
    `
  let userName = sessionStorage.getItem('User_Name') || ''
  let fullName = sessionStorage.getItem('Full_Name') || ''
  let RoleID = sessionStorage.getItem('role_id') || ''
  let departmentcode = sessionStorage.getItem('departmentcode') || ''
  let organization = sessionStorage.getItem('organization') || ''
  let city = sessionStorage.getItem('city') || ''
  if (sessionStorage.getItem('isEditState') === 'true') {
    userName = sessionStorage.getItem('CloudUserName') || ''
    fullName = sessionStorage.getItem('CloudFullName') || ''
  }
  // 初始化凭证及用户信息字段
  _sql += `
      /* 凭证及用户信息初始化赋值 */
      select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @login_city='${city}', @BillCode='', @ModularDetailCode=''
      `
  // 表单变量赋值
  if (_initFormfields.length > 0) {
    _sql += `
@@ -1597,24 +1617,6 @@
  if (verify.billcodes) {
    verify.billcodes = verify.billcodes.filter(item => item.status !== 'false')
  }
  let userName = sessionStorage.getItem('User_Name') || ''
  let fullName = sessionStorage.getItem('Full_Name') || ''
  let RoleID = sessionStorage.getItem('role_id') || ''
  let departmentcode = sessionStorage.getItem('departmentcode') || ''
  let organization = sessionStorage.getItem('organization') || ''
  let city = sessionStorage.getItem('city') || ''
  if (sessionStorage.getItem('isEditState') === 'true') {
    userName = sessionStorage.getItem('CloudUserName') || ''
    fullName = sessionStorage.getItem('CloudFullName') || ''
  }
  // 初始化凭证及用户信息字段
  _sql += `
      /* 凭证及用户信息初始化赋值 */
      select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @login_city='${city}', @BillCode='', @ModularDetailCode=''
      `
  if (retmsg) {
    _callbacksql = _sql
@@ -2102,7 +2104,7 @@
      aaa: select @ErrorCode as ErrorCode,@retmsg as retmsg`
  }
  if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
  if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
    // _sql = _sql.replace(/\n\s{8}/ig, '\n')
    console.info(_sql)
  }