From 78db2a9b5e94b8a95f0735596e38410c24f990ea Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 08 四月 2025 17:46:43 +0800
Subject: [PATCH] Merge branch 'develop'
---
src/utils/utils-datamanage.js | 202 +++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 190 insertions(+), 12 deletions(-)
diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js
index 961119b..9507763 100644
--- a/src/utils/utils-datamanage.js
+++ b/src/utils/utils-datamanage.js
@@ -5,6 +5,136 @@
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 鏁版嵁婧愮粺涓�鏌ヨ
@@ -13,17 +143,23 @@
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
@@ -497,8 +633,17 @@
/**
* @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
@@ -555,7 +700,7 @@
return {
uuid: uuid,
- name: dataName,
+ dataName: dataName,
$name: setting.$name,
columns: columns,
par_tablename: '',
@@ -572,6 +717,39 @@
* @description 鐢熸垚sPC_Get_structured_data璇锋眰鍙傛暟
*/
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
@@ -611,9 +789,9 @@
}
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 = {
--
Gitblit v1.8.0