king
2020-03-26 e0f1f05b7567a7bfd29fd5ad54e4b2222ddfcb94
src/utils/utils.js
@@ -1,5 +1,6 @@
import moment from 'moment'
import md5 from 'md5'
import options from '@/store/options.js'
const service = window.GLOB.service ? (/\/$/.test(window.GLOB.service) ? window.GLOB.service : window.GLOB.service + '/') : ''
@@ -193,7 +194,9 @@
        key: search.field,
        match: search.match,
        type: search.type,
        value: search.initval
        label: search.label,
        value: search.initval,
        required: search.required === 'true'
      }
      if (item.type === 'date') {
        item.value = item.value ? moment().subtract(item.value, 'days').format('YYYY-MM-DD') : ''
@@ -288,6 +291,12 @@
        newsearches[item.key] = item.value
      }
    })
    Object.keys(newsearches).forEach(key => {
      if (!newsearches[key]) {
        delete newsearches[key]
      }
    })
    
    return newsearches
  }
@@ -317,12 +326,8 @@
        searchText += item.key + ' ' + item.match + ' \'' + str + item.value + str + '\''
      } else if (item.type === 'multiselect') {
        let str = item.match === '=' ? '' : '%'
        let options = item.value.map(val => {
          return item.key + ' ' + item.match + ' \'' + str + val + str + '\''
        })
        searchText += '(' + options.join(' OR ') + ')'
        searchText += `'${item.value}' ` + item.match + ' \'%\'+' + item.key + '+\'%\''
      } else if (item.type === 'date') {
        let _val = item.value
        let timetail = ' 00:00:00.000'
@@ -355,6 +360,7 @@
        searchText += '(' + item.key + ' ' + item.match + ' \'' + item.value + '\')'
      }
    })
    return searchText
  }
@@ -391,6 +397,7 @@
   */
  static getrealurl (url) {
    if (!url) return ''
    let baseurl = ''
    if (process.env.NODE_ENV === 'production') {
      baseurl = document.location.origin + '/' + service
@@ -402,6 +409,24 @@
    // }
    let realurl = url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url
    return realurl
  }
  /**
   * @description 获取云端图片真实路径
   * @return {String}    url 图片路径
   */
  static getcloudurl (url) {
    if (!url) return ''
    let baseurl = ''
    if (options.cloudServiceApi) {
      baseurl = options.cloudServiceApi.replace(/webapi(.*)$/, '')
    } else {
      baseurl = document.location.origin + '/' + service
    }
    return url.match(/^http/) || url.match(/^\/\//) ? url : baseurl + url
  }
  /**
@@ -606,7 +631,6 @@
    let _formFieldValue = {}
    // 需要声明的变量集
    // let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey']
    // let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey']
    let _vars = ['tbid', 'errorcode', 'retmsg', 'billcode', 'bvoucher', 'fibvoucherdate', 'fiyear', 'username', 'fullname', 'modulardetailcode']
    // 主键字段
@@ -617,7 +641,6 @@
      `
    // let _initvars = ['ID', 'BID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey'] // 已赋值字段集
    // let _initvars = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'] // 已赋值字段集
    let _initvars = [] // 已赋值字段集
    let _initfields = []
    let _declarefields = []
@@ -706,11 +729,6 @@
        `
    }
    // 添加时主键为空 改为前台生成
    // if (btn.sqlType === 'insert') {
    //   primaryId = ''
    // }
    // 去除禁用的验证
    if (verify.contrasts) {
      verify.contrasts = verify.contrasts.filter(item => item.status !== 'false')
@@ -728,8 +746,16 @@
      verify.scripts = verify.scripts.filter(item => item.status !== 'false')
    }
    // 初始化凭证字段
    _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg=''
    let userName = sessionStorage.getItem('User_Name') || ''
    let fullName = sessionStorage.getItem('Full_Name') || ''
    if (sessionStorage.getItem('isEditState') === 'true') {
      userName = sessionStorage.getItem('CloudUserName') || ''
      fullName = sessionStorage.getItem('CloudFullName') || ''
    }
    // 初始化凭证及用户信息字段
    _sql += `select @BVoucher='',@FIBVoucherDate='',@FiYear='',@ErrorCode='',@retmsg='',@UserName='${userName}', @FullName='${fullName}'
      `
    // 启用账期验证
@@ -898,10 +924,6 @@
        `
    }
    // 用于取用户信息
    let _user = `select @UserName=UserName,@FullName=FullName from SUsers where UID=@UserID@
      `
    let primaryKeyName = ['id', 'bid', 'loginuid', 'sessionuid', 'userid', 'appkey'].includes(primaryKey.toLowerCase()) ? primaryKey + '@' : primaryKey
    let _actionType = null
@@ -951,7 +973,6 @@
      keys = keys.join(',')
      values = values.join(',')
      _sql += _user
      _sql += `insert into ${btn.sql} (${keys}) select ${values};`
    } else if (_actionType === 'update') {
      let _form = []
@@ -1003,7 +1024,6 @@
          }
        })
      }
      _sql += _user
      _sql += `insert into snote (remark,createuserid,CreateUser,CreateStaff) select '删除表:${btn.sql} 数据: ${_msg}${primaryKey}='+@${primaryKeyName},@userid@,@username,@fullname delete ${btn.sql} where ${primaryKey}=@${primaryKeyName};`
    }
@@ -1092,6 +1112,7 @@
    let Ltext = `create proc ${param.innerFunc}
    ( /*${menu.MenuName}*/
    @appkey nvarchar(50)='',
    @BID nvarchar(50)='',${formParam}
    @PageIndex nvarchar(50)='',
    @PageSize nvarchar(50)='',
@@ -1249,8 +1270,15 @@
      `
    }
    // 打印自定义模板字段提示
    let _printRemark = ''
    if (btn.funcType === 'print') {
      _printRemark = '/* 自定义数据打印模板时,请使用TemplateID字段 */'
    }
    let Ltext = `create proc ${param.funcName}
    ( /*${menu.MenuName}  ${btn.label}*/
    @appkey nvarchar(50)='',
    @BID nvarchar(50)='',${formParam}
    @sEPTMenuNo nvarchar(50)='${param.menuNo}',
    @lang nvarchar(50)='',
@@ -1271,7 +1299,7 @@
      /*事务操作*/
      BEGIN TRAN
        /*具体业务操作*/
        ${_printRemark}
        /* 
        select top 10 * from sProcExcep order by id desc
        
@@ -1358,10 +1386,13 @@
    let Ltext = `create proc ${param.funcName}
    ( /*${menu.MenuName}  ${btn.label}*/
      @appkey nvarchar(50)='',
      @ID nvarchar(50)='',
      @BID nvarchar(50)='',
      @Ltext nvarchar(max)='',
      @sEPTMenuNo nvarchar(50)='${param.menuNo}', 
      @secretkey nvarchar(50)='',
      @timestamp nvarchar(50)='',
      @lang nvarchar(50)='',
      @LoginUID nvarchar(50)='',
      @SessionUid nvarchar(50)='',