king
8 天以前 a1e9b18a4dbfd21e1bf4d5cb60974ac2f0115efd
src/utils/utils-datamanage.js
@@ -1,32 +1,165 @@
import md5 from 'md5'
import moment from 'moment'
import { notification, Modal } from 'antd'
import MKEmitter from '@/utils/events.js'
import Utils from './utils.js'
const getBackendQueryParam = (setting, search, orderBy, pageIndex, pageSize, id, BID, year, dataName) => {
  let item = window.GLOB.CacheData.get('sql_' + setting.uuid)
  let searchKeys = null
  if (setting.dataresource) {
    searchKeys = []
    if (search.length && setting.queryType !== 'statistics') {
      searchKeys = Utils.getSearchkeys(search)
    }
    if (id) {
      if (/^excel:/.test(id)) {
        id = id.replace(/^excel:/, '')
        searchKeys.push({
          key: setting.primaryKey || 'ID',
          match: '',
          type: 'text_in',
          value: id
        })
      } else {
        searchKeys.push({
          key: setting.primaryKey || 'ID',
          match: '03',
          type: 'text',
          value: id
        })
      }
    }
  }
  let values = {
    time_id: Utils.getguid(),
    roleid: sessionStorage.getItem('role_id') || '',
    mk_departmentcode: sessionStorage.getItem('departmentcode') || '',
    mk_organization: sessionStorage.getItem('organization') || '',
    mk_user_type: sessionStorage.getItem('mk_user_type') || '',
    mk_nation: sessionStorage.getItem('nation') || '',
    mk_province: sessionStorage.getItem('province') || '',
    mk_city: sessionStorage.getItem('city') || '',
    mk_district: sessionStorage.getItem('district') || '',
    mk_address: sessionStorage.getItem('address') || '',
    orderby: orderBy || '',
    pagesize: setting.laypage ? pageSize : '9999',
    pageindex: pageIndex,
    id: id || '',
    bid: BID || '',
    typename: 'admin',
    datam: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
    datam_begin: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
    datam_end: sessionStorage.getItem('dataM') === 'true' ? 'Y' : '',
    mk_obj_name: dataName || 'data'
  }
  if (setting.hasExtend) {
    values.mk_time = setting.extendTime
  }
  if (setting.$re_year) {
    values.mk_year = year
  }
  if (window.GLOB.externalDatabase !== null) {
    values.db = window.GLOB.externalDatabase
  }
  if (item.works_flow_code) {
    values.works_flow_code = item.works_flow_code
  }
  item.urlkeys && item.urlkeys.forEach(key => {
    if (values.hasOwnProperty(key.toLowerCase())) return
    values[key] = item.urlparam[key]
  })
  let allSearch = Utils.getAllSearchOptions(search)
  allSearch.forEach(cell => {
    values[cell.key.toLowerCase()] = cell.value
  })
  let exps = []
  if (searchKeys) {
    exps.push({
      key: 'mk_search',
      value: searchKeys
    })
  }
  item.reps.forEach(n => {
    let key = n.toLowerCase()
    if (values.hasOwnProperty(key)) {
      exps.push({
        key: n,
        value: values[key]
      })
    }
  })
  let md5_id = ''
  if (window.GLOB.probation) {
    md5_id = md5(item.id + JSON.stringify(exps) + Math.floor(new Date().getTime() / 600000))
    md5_id = moment().format('YYYYMMDDHHmmss') + md5_id.slice(-18)
  }
  let cell = {
    id: item.id,
    menuname: setting.$name || '',
    exps: exps,
    md5_id: md5_id
  }
  if (dataName) {
    cell.dataName = dataName
    cell.luser = item.luser
    return cell
  }
  let param = {
    $backend: true,
    $type: 's_Get_TableData',
    data: [cell]
  }
  if (setting.database === 'sso' && window.GLOB.mainSystemApi) {
    param.rduri = window.GLOB.mainSystemApi
  }
  return param
}
export default class DataUtils {
  /**
   * @description 数据源名称,用于统一查询
   * @param {Object}   setting      数据源设置
   * @param {Array}    search       搜索条件
   * @param {String}   orderBy      排序方式
   * @param {Number}   pageIndex    页码
   * @param {Number}   pageSize     每页数量
   * @param {String}   BID          上级ID
   * @description 数据源统一查询
   */
  static getQueryDataParams (setting, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, id, year) {
    let param = null
    if (setting.interType === 'system') {
      param = this.getDefaultQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year)
      if (window.backend && window.GLOB.CacheData.has('sql_' + setting.uuid)) {
        param = getBackendQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year)
      } else {
        param = this.getDefaultQueryParam(setting, search, orderBy, pageIndex, pageSize, id, BID, year)
        param.BID = BID || ''
        param.dataM = sessionStorage.getItem('dataM') === 'true' ? 'Y' : ''
      }
    } else {
      param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, id, year)
    }
    if (BID) {
      param.BID = BID
    }
    // 数据管理权限
    if (sessionStorage.getItem('dataM') === 'true') {
      param.dataM = 'Y'
      if (BID) {
        param.BID = BID
      }
      // 数据管理权限
      if (sessionStorage.getItem('dataM') === 'true') {
        param.dataM = 'Y'
      }
    }
    return param
@@ -51,6 +184,10 @@
      param.mk_year = year
    }
    if (setting.hasExtend) {
      param.mk_time = setting.extendTime
    }
    if (setting.interType === 'inner') {
      param.func = setting.innerFunc
@@ -59,35 +196,31 @@
        param.fullname = sessionStorage.getItem('Full_Name') || ''
      }
    } else {
      if (window.GLOB.mkHS) {
        if (setting.sysInterface === 'true' && window.GLOB.cloudServiceApi) {
          param.rduri = window.GLOB.cloudServiceApi
          param.userid = sessionStorage.getItem('CloudUserID') || ''
          param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
        } else if (setting.sysInterface !== 'true') {
      if (setting.sysInterface === 'true') {
        if (window.GLOB.mainSystemApi) {
          param.rduri = window.GLOB.mainSystemApi
        }
      } else if (setting.sysInterface === 'external') {
        if (window.GLOB.systemType === 'production') {
          param.$token = setting.exProInterface || ''
        } else {
          param.$token = setting.exInterface || ''
        }
      } else if (setting.sysInterface === 'custom') {
        if (window.GLOB.systemType === 'production') {
          param.rduri = setting.proInterface
        } else {
          param.rduri = setting.interface
        }
      } else {
        if (setting.sysInterface === 'true') {
          if (window.GLOB.mainSystemApi) {
            param.rduri = window.GLOB.mainSystemApi
          }
        } else if (setting.sysInterface === 'external') {
          if (window.GLOB.systemType === 'production') {
            param.$token = setting.exProInterface || ''
          } else {
            param.$token = setting.exInterface || ''
          }
        if (window.GLOB.systemType === 'production' && setting.proInterface) {
          param.rduri = setting.proInterface
        } else {
          if (window.GLOB.systemType === 'production' && setting.proInterface) {
            param.rduri = setting.proInterface
          } else {
            param.rduri = setting.interface
          }
          let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
          if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
            param.$login = true
          }
          param.rduri = setting.interface
        }
        let host = window.GLOB.baseurl.replace(/http(s):\/\//, '')
        if (param.rduri.indexOf(host) === -1 && /\/dostars/.test(param.rduri)) {
          param.$login = true
        }
      }
@@ -106,7 +239,7 @@
    let param = {
      func: 'sPC_Get_TableData',
      obj_name: 'data',
      exec_type: 'y',
      exec_type: window.GLOB.execType || 'y',
      arr_field: setting.arr_field,
      default_sql: setting.execute ? 'true' : 'false'
    }
@@ -145,20 +278,24 @@
      { reg: /@orderBy@/ig, value: orderBy },
      { reg: /@pageSize@/ig, value: setting.laypage ? pageSize : '9999' },
      { reg: /@pageIndex@/ig, value: pageIndex},
      { reg: /@select\$|\$select@/ig, value: ''},
      { reg: /\$sum@/ig, value: '/*'},
      { reg: /@sum\$/ig, value: '*/'},
      // { reg: /@select\$|\$select@/ig, value: ''},
      // { reg: /\$sum@/ig, value: '/*'},
      // { reg: /@sum\$/ig, value: '*/'},
      { reg: /@ID@/ig, value: `'${id || ''}'`},
      { reg: /@BID@/ig, value: `'${BID || ''}'`},
      { reg: /@LoginUID@/ig, value: `'${sessionStorage.getItem('LoginUID') || ''}'`},
      { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`},
      { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`},
      { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`},
      { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`},
      { reg: /@typename@/ig, value: `'admin'`},
    )
    if (setting.hasExtend) {
      regoptions.push({ reg: /@mk_time@/ig, value: `'${setting.extendTime}'` })
    }
    if (setting.$re_year) {
      regoptions.push({ reg: /@mk_year@/ig, value: year })
      regoptions.push({ reg: /@mk_year@/ig, value: `'${year}'` })
    }
    regoptions.forEach(item => {
@@ -214,15 +351,28 @@
        } else {
          DateCount = `/*system_query*/select count(1) as total from ${_dataresource} ${_search}`
        }
      } else if (setting.$top) {
        if (orderBy) {
          LText = `/*system_query*/select top 1 ${arr_field} from ${_dataresource} ${_search} order by ${orderBy} `
        } else {
          LText = `/*system_query*/select top 1 ${arr_field} from ${_dataresource} ${_search}  `
        }
      } else if (orderBy) {
        LText = `/*system_query*/select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows `
        LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search} order by ${orderBy} `
      } else {
        LText = `/*system_query*/select ${arr_field} from ${_dataresource} ${_search}  `
      }
    }
    if (_customScript) {
      if (LText) {
      if (DateCount) {
        DateCount = `${DateCount}
          ${_tailScript}
          aaa:
          if @ErrorCode!=''
            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}'
        `
      } else if (LText) {
        LText = `${LText}
          ${_tailScript}
          aaa:
@@ -237,6 +387,17 @@
            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' 
        `
      }
    } else if (_tailScript && DateCount) {
      LText = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100)
        Select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}'
        ${LText}
      `
      DateCount = `${DateCount}
        ${_tailScript}
        aaa:
        if @ErrorCode!=''
          insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}'
      `
    } else if (_tailScript) {
      LText = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100)
        Select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}'
@@ -255,17 +416,18 @@
    // 测试系统打印查询语句
    if (window.GLOB.debugger === true) {
      _customScript && console.info(`${setting.$name ? `/*${setting.$name} 自定义脚本*/\n` : ''}${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      LText && console.info(`${setting.$name ? `/*${setting.$name} 数据源*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n'))
      _customScript && window.mkInfo(`${setting.$name ? `/*${setting.$name} 自定义脚本*/\n` : ''}${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      LText && window.mkInfo(`${setting.$name ? `/*${setting.$name} 数据源*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n'))
      DateCount && window.mkInfo(`${setting.$name ? `/*${setting.$name} 总数查询*/\n` : ''}` + DateCount.replace(/\n\s{8}/ig, '\n'))
    }
    if (setting.$name) {
      param.menuname = setting.$name
    }
    param.custom_script = Utils.formatOptions(_customScript)
    param.LText = Utils.formatOptions(LText)
    param.DateCount = Utils.formatOptions(DateCount)
    param.custom_script = Utils.formatOptions(_customScript, param.exec_type)
    param.LText = Utils.formatOptions(LText, param.exec_type)
    param.DateCount = Utils.formatOptions(DateCount, param.exec_type)
    if (setting.sub_field) {
      param.sub_name = setting.subdata
@@ -274,9 +436,9 @@
      param.sub_field = setting.sub_field
    }
    // exec_type: 'y' 解码字段:LText、LText1、LText2、custom_script、DateCount
    // exec_type 解码字段:LText、LText1、LText2、custom_script、DateCount
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss.SSS')
    param.secretkey = Utils.encrypt('', param.timestamp)
    param.username = userName
@@ -290,11 +452,15 @@
      param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
      // special HS自定义函数查询
      if (setting.tableName === 's_custom_script' && window.GLOB.cloudServiceApi) {
        param.rduri = window.GLOB.cloudServiceApi
        param.userid = sessionStorage.getItem('CloudUserID') || ''
        param.LoginUID = sessionStorage.getItem('CloudLoginUID') || ''
      if (setting.tableName === 's_custom_script' && window.GLOB.mainSystemApi) {
        param.rduri = window.GLOB.mainSystemApi
      }
    } else if (window.GLOB.forcedUpdate) {
      param.s_version_up = 'true'
    }
    if (setting.database === 'sso' && window.GLOB.mainSystemApi) {
      param.rduri = window.GLOB.mainSystemApi
    }
    return param
@@ -307,7 +473,7 @@
    let param = {
      func: 'sPC_Get_TableData',
      obj_name: 'data',
      exec_type: 'y',
      exec_type: window.GLOB.execType || 'y',
      arr_field: statFields.map(col => col.field).join(','),
      default_sql: setting.execute ? 'true' : 'false'
    }
@@ -345,15 +511,16 @@
      { reg: /@orderBy@/ig, value: orderBy },
      { reg: /@pageSize@/ig, value: 999999 },
      { reg: /@pageIndex@/ig, value: 1},
      { reg: /\$select@/ig, value: '/*'},
      { reg: /@select\$/ig, value: '*/'},
      { reg: /@sum\$|\$sum@/ig, value: ''},
      // { reg: /\$select@/ig, value: '/*'},
      // { reg: /@select\$/ig, value: '*/'},
      // { reg: /@sum\$|\$sum@/ig, value: ''},
      { reg: /@ID@/ig, value: `''`},
      { reg: /@BID@/ig, value: `'${BID || ''}'`},
      { reg: /@LoginUID@/ig, value: `'${sessionStorage.getItem('LoginUID') || ''}'`},
      { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`},
      { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`},
      { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`},
      { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`},
      { reg: /@typename@/ig, value: `'admin'`},
    )
@@ -388,16 +555,16 @@
    // 测试系统打印查询语句
    if (window.GLOB.debugger === true) {
      _customScript &&  console.info(`${setting.$name ? `/*${setting.$name} 自定义脚本 统计查询*/\n` : ''}${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      LText &&  console.info(`${setting.$name ? `/*${setting.$name} 数据源 统计查询*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n'))
      _customScript && window.mkInfo(`${setting.$name ? `/*${setting.$name} 自定义脚本 统计查询*/\n` : ''}${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`)
      LText && window.mkInfo(`${setting.$name ? `/*${setting.$name} 数据源 统计查询*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n'))
    }
    if (setting.$name) {
      param.menuname = setting.$name
    }
    
    param.custom_script = Utils.formatOptions(_customScript)
    param.LText = Utils.formatOptions(LText)
    param.custom_script = Utils.formatOptions(_customScript, param.exec_type)
    param.LText = Utils.formatOptions(LText, param.exec_type)
    param.DateCount = ''
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
@@ -421,13 +588,62 @@
    return param
  }
  /**
   * @description 数据获取成功
   */
  static querySuccess (result) {
    if (!result.message) return
    if (result.ErrCode === 'Y') {
      Modal.success({
        title: result.message
      })
    } else if (result.ErrCode === 'S') {
      notification.success({
        top: 92,
        message: result.message,
        duration: 2
      })
    }
  }
  /**
   * @description 数据获取失败
   */
  static queryFail (result) {
    if (!result.message && result.ErrCode !== 'version_up') return
    if (result.ErrCode === 'N') {
      Modal.error({
        title: result.message,
      })
    } else if (result.ErrCode === 'version_up') {
      MKEmitter.emit('reloadTabs')
    } else if (result.ErrCode !== '-2') {
      notification.error({
        top: 92,
        message: result.message,
        duration: 10
      })
    }
  }
}
/**
 * @description 生成单个组件sPC_Get_structured_data请求参数
 */
export function getStructDefaultParam (component, searchlist, first) {
export function getStructDefaultParam (component, searchlist, first, BID) {
  const { columns, setting, dataName, format, uuid } = component
  if (window.backend && window.GLOB.CacheData.has('sql_' + uuid)) {
    if (first) {
      let item = window.GLOB.CacheData.get('sql_' + uuid)
      window.GLOB.CacheData.set('first_' + item.id, uuid)
    }
    return getBackendQueryParam(setting, searchlist, setting.order, 1, 1000, '', BID, '', dataName)
  }
  let _dataresource = setting.dataresource
  let _customScript = setting.customScript
@@ -445,21 +661,20 @@
    _customScript = _customScript.replace(item.reg, item.value)
  })
  // _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '')
  // _customScript = _customScript.replace(/@select\$|\$select@/ig, '')
  // _dataresource = _dataresource.replace(/\$sum@/ig, '/*')
  // _dataresource = _dataresource.replace(/@sum\$/ig, '*/')
  // _customScript = _customScript.replace(/\$sum@/ig, '/*')
  // _customScript = _customScript.replace(/@sum\$/ig, '*/')
  let _search = ''
  if (setting.queryType !== 'statistics' && _dataresource) {
    _search = Utils.joinMainSearchkey(searchlist)
    _search = _search ? 'where ' + _search : ''
  }
  if (setting.order && _dataresource) {
    _dataresource = `select top 1000 ${setting.arr_field} from (select ${setting.arr_field} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows `
  if (setting.$top) {
    if (setting.order && _dataresource) {
      _dataresource = `select top 1 ${setting.arr_field} from ${_dataresource} ${_search} order by ${setting.order} `
    } else if (_dataresource) {
      _dataresource = `select top 1 ${setting.arr_field} from ${_dataresource} ${_search} `
    }
  } else if (setting.order && _dataresource) {
    _dataresource = `select top 1000 ${setting.arr_field} from ${_dataresource} ${_search} order by ${setting.order} `
  } else if (_dataresource) {
    _dataresource = `select top 1000 ${setting.arr_field} from ${_dataresource} ${_search} `
  }
@@ -485,7 +700,7 @@
  return {
    uuid: uuid,
    name: dataName,
    dataName: dataName,
    $name: setting.$name,
    columns: columns,
    par_tablename: '',
@@ -494,16 +709,47 @@
    primaryKey: setting.primaryKey || '',
    foreign_key: '',
    sql: _dataresource,
    script: _customScript,
    // transaction: setting.transaction === 'true'
    script: _customScript
  }
}
/**
 * @description 生成sPC_Get_structured_data请求参数
 * 1、把大接口sPC_Get_structured_data的ltext拆成三份,第一段:@LText1,第二段@LText,第三段@LText2
 */
export function getStructuredParams (params, config, BID) {
  if (window.backend && params[0].exps) {
    let param = {
      $backend: true,
      $type: 's_Get_structured_data',
      data: params.map(item => {
        let cell = {...item}
        delete cell.dataName
        delete cell.luser
        return cell
      })
    }
    if (config.cacheUseful === 'true') {
      param.time_limit = config.cacheTime
      if (config.timeUnit === 'day') {
        param.time_limit = param.time_limit * 1440
      } else if (config.timeUnit === 'hour') {
        param.time_limit = param.time_limit * 60
      }
      if (params.findIndex(item => item.luser) > -1) {
        param.data_md5 = md5(window.GLOB.appkey + params[0].id + sessionStorage.getItem('UserID'))
      } else {
        param.data_md5 = md5(window.GLOB.appkey + params[0].id)
      }
    }
    return param
  }
  let LText_field = []
  let diffUser = false
@@ -516,6 +762,7 @@
    { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`},
    { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`},
    { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`},
    { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`},
    { reg: /@typename@/ig, value: `'admin'`},
  ]
@@ -537,35 +784,28 @@
    // 测试系统打印查询语句
    if (window.GLOB.debugger === true) {
      _script && console.info(`${item.$name ? `/*${item.$name} 自定义脚本(同步查询)*/\n` : ''}${_sql ? '' : '/*不执行默认sql*/\n'}${_script}`)
      _sql && console.info(`${item.$name ? `/*${item.$name} 数据源(同步查询)*/\n` : ''}` + _sql)
      _script && window.mkInfo(`${item.$name ? `/*${item.$name} 自定义脚本(同步查询)*/\n` : ''}${_sql ? '' : '/*不执行默认sql*/\n'}${_script}`)
      _sql && window.mkInfo(`${item.$name ? `/*${item.$name} 数据源(同步查询)*/\n` : ''}` + _sql)
    }
    item.columns.forEach(cell => {
      LText_field.push(`Select '${item.name}' as tablename,'${cell.field}' as fieldname,'${cell.datatype}' as field_type`)
      LText_field.push(`Select '${item.dataName}' as tablename,'${cell.field}' as fieldname,'${cell.datatype}' as field_type`)
    })
    return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(_sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort`
    return `Select '${item.dataName}' as tablename,'${window.btoa(window.encodeURIComponent(_sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort`
  })
  let param = {
    func: 'sPC_Get_structured_data',
    LText: _LText.join(' union all '),
    LText_field: LText_field.join(' union all '),
    BID: BID,
    username: sessionStorage.getItem('User_Name') || '',
    fullName: sessionStorage.getItem('Full_Name') || ''
  }
  if (config.MenuName) {
    param.menuname = config.MenuName
  }
  param.menuname = config.MenuName || config.$menuname || ''
  let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText)
  param.LText1 = LText1
  param.LText = LText
  param.LText2 = LText2
  param.LText_field = Utils.formatOptions(param.LText_field)
  param.exec_type = window.GLOB.execType || 'y'
  param.LText = Utils.formatOptions(_LText.join(' union all '), param.exec_type)
  param.custom_script = Utils.formatOptions(LText_field.join(' union all '), param.exec_type)
  if (config.cacheUseful === 'true') {
    param.time_type = config.timeUnit
@@ -577,7 +817,7 @@
  }
  param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
  param.secretkey = Utils.encrypt(param.LText, param.timestamp)
  param.secretkey = Utils.encrypt('', param.timestamp)
  return param
}