From 4a98e265a3b2a9bf5d07cc2789593b1abff0e0f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E9=98=94?= Date: Sat, 9 Nov 2024 18:01:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8C=87=E6=A0=87=E5=8A=A0?= =?UTF-8?q?=E5=B7=A5=E7=9A=84=E5=8A=9F=E8=83=BD=EF=BC=8C=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E6=A0=BC=E5=BC=8F=E5=8C=96sql=E5=8A=9F?= =?UTF-8?q?=E8=83=BDnpm=20install=20sql-formatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/dataManage/dataSourceManage/index.ts | 2 +- src/components/Dialog/src/Dialog.vue | 7 +- .../PreViewFile/src/PreViewFile.vue | 61 ++-- src/store/modules/targetRule.ts | 288 ++++++++++++++++++ .../components/ProcedureConfig.vue | 35 ++- src/views/IndexProcess/SqlRule/SqlRule.vue | 35 ++- .../SqlRule/components/BasicInfo.vue | 133 +++++--- .../SqlRule/components/SetParams.vue | 207 ++++++++++--- src/views/IndexProcess/SqlRule/constants.ts | 0 src/views/IndexProcess/constants.ts | 65 ++++ src/views/dataset/CodeRepItem/CodeRepItem.vue | 55 +++- .../CodeRepItem/components/RuleConfig.vue | 20 +- .../IndexSearchServiceMs.vue | 30 +- .../components/DataDillingByOrgan.vue | 92 ++++++ .../components/DrillingOrAnalysis.vue | 85 ++++++ .../components/TrendAnalysis.vue | 1 + src/views/dataset/RepSetRule/RepSetRule.vue | 19 +- .../dataset/RepSetRule/components/Detail.vue | 91 ------ 18 files changed, 949 insertions(+), 277 deletions(-) create mode 100644 src/store/modules/targetRule.ts delete mode 100644 src/views/IndexProcess/SqlRule/constants.ts create mode 100644 src/views/IndexProcess/constants.ts create mode 100644 src/views/dataset/IndexSearchServiceMs/components/DataDillingByOrgan.vue create mode 100644 src/views/dataset/IndexSearchServiceMs/components/DrillingOrAnalysis.vue create mode 100644 src/views/dataset/IndexSearchServiceMs/components/TrendAnalysis.vue delete mode 100644 src/views/dataset/RepSetRule/components/Detail.vue diff --git a/src/api/dataManage/dataSourceManage/index.ts b/src/api/dataManage/dataSourceManage/index.ts index 189d02a..ee1bb31 100644 --- a/src/api/dataManage/dataSourceManage/index.ts +++ b/src/api/dataManage/dataSourceManage/index.ts @@ -3,7 +3,7 @@ import type { TableData } from './types'; /** 获取表格数据 */ export const getTableList = (data: any) => { - return request.postJson({ url: '/system/spi/system/RepDataSource/RepDataSourceQueryPage', data }); + return request.postJson({ url: '/param/spi/param/RepDataSource/RepDataSourceQueryPage', data }); }; /** 批量删除 */ diff --git a/src/components/Dialog/src/Dialog.vue b/src/components/Dialog/src/Dialog.vue index 7bba971..175bd2a 100644 --- a/src/components/Dialog/src/Dialog.vue +++ b/src/components/Dialog/src/Dialog.vue @@ -10,7 +10,8 @@ const props = defineProps({ modelValue: propTypes.bool.def(false), title: propTypes.string.def('Dialog'), fullscreen: propTypes.bool.def(true), - maxHeight: propTypes.oneOfType([String, Number]).def('400px') + maxHeight: propTypes.oneOfType([String, Number]).def('400px'), + ISFullScreen:propTypes.bool.def(false), }) const getBindValue = computed(() => { @@ -25,10 +26,10 @@ const getBindValue = computed(() => { return obj }) -const isFullscreen = ref(false) +let isFullscreen = ref(props.ISFullScreen) const toggleFull = () => { - isFullscreen.value = !unref(isFullscreen) + isFullscreen.value = !isFullscreen.value; } const dialogHeight = ref(isNumber(props.maxHeight) ? `${props.maxHeight}px` : props.maxHeight) diff --git a/src/components/PreViewFile/src/PreViewFile.vue b/src/components/PreViewFile/src/PreViewFile.vue index 16c56c3..13c0bde 100644 --- a/src/components/PreViewFile/src/PreViewFile.vue +++ b/src/components/PreViewFile/src/PreViewFile.vue @@ -1,30 +1,32 @@ @@ -166,9 +168,9 @@ const TurnBlobForRender = async (data) => { await generateThumbnails(); renderAllPages(); currentPage.value = 0;//初始化当前页为第一页 - let loading = ref(false); + loading.value = false; } catch (error) { - let loading = ref(false); + loading.value = false; console.error('Error loading PDF:', error); } }; @@ -179,7 +181,7 @@ const TurnBlobForRender = async (data) => { }; //从后台获取文件流 const fetchDocFile = async () => { - let loading = ref(true); + loading.value = true; // 这里假设你有一个 API 可以返回 DOCX 文件的 ArrayBuffer const response = await queryFileFlowRepTemplateApi(params); const { data, headers } = response; @@ -195,7 +197,7 @@ const fetchDocFile = async () => { ElMessage.error(downLoadErrorMsg['1003']); break; } - let loading = ref(false); + loading.value = false; return; } BlobFile.value = response; @@ -217,7 +219,6 @@ const handleFileChange = async (event) => { } const fileReader = new FileReader(); fileReader.onload = async (e) => { - console.log(e,"文件信息"); const typedArray = new Uint8Array(e.target.result); try { pdfDocument.value = await pdfjsLib.getDocument({ data: typedArray }).promise; diff --git a/src/store/modules/targetRule.ts b/src/store/modules/targetRule.ts new file mode 100644 index 0000000..87b04ee --- /dev/null +++ b/src/store/modules/targetRule.ts @@ -0,0 +1,288 @@ +//新增规则信息 +import { defineStore } from 'pinia'; +import { store } from '../index'; +import { useStorage } from '@/hooks/web/useStorage'; +import { useAppStoreWithOut } from './app' + +const appStore = useAppStoreWithOut() + +const { getStorage } = useStorage() +/** + * 关联表 + */ +export interface QueryDefs { + /** 表ID */ + id: string; + /** 表名 */ + table?: string; + /** 表名/注释名称 */ + displayName?: string; + /** 表别名 */ + tableAlias?: string; + /** 数据库名 */ + schema?: string; + /** 上级表ID */ + parentQueryDef?: string; + /** 关联字段 */ + relationshipFields?: RelationshipFields[]; + /** 级别 */ + level?: number; + /** 本表字段 */ + rightOptions?: FieldDefs[]; + /** 关联关系,left/inner join */ + relationship?: string; + sql?: string; +} +/** + * 关联字段 + */ +export interface RelationshipFields { + /** 主表字段 */ + leftField: string; + /** 字段 */ + rightField: string; +} +export enum Oprator { + and = 'and', + or = 'or', +} +export interface Rules { + /** ID */ + id: string; + /** 表信息ID */ + queryDefsId: string; + /** 字段名称 */ + fieldId: string; + /** 表信息ID + 字段名称 */ + fullId: string; + /** 别名 */ + alia: string; + /** 字段类型 */ + type: string; + /** 表达式 */ + consy: string; + /** 函数名 */ + funName?: string; + /** 表达式里的值 */ + value?: string | number | string[] | number[]; + /** 正则 */ + regexp?: string; +} +export interface ConditionDefts { + /** ID */ + id: string; + /** 上级ID,根节点设为null */ + parent: string | null; + /** 逻辑 */ + oprator: Oprator; + /** 过滤条件具体数据 */ + rules: Rules[]; + /** 分组过滤条件 */ + rulesGroup?: ConditionDefts[]; + /** sql */ + sql?: string; +} +export interface FieldDefs { + id: string; + /** 表信息ID */ + queryDefsId?: string; + /** 表名 */ + tableName: string; + /** 表别名 */ + tableAlias?: string; + /** 数据库原始名称 */ + dbName?: string; + /** 数据库原始名称 */ + fieldName?: string; + /** 字段注释 */ + remarks?: string; + /** 字段类型 */ + fieldType?: string; + columnType?: string; // 列类型 + isUse?: string; // 是否使用 + /** 字段Java类型 */ + javaType?: string; + formula?: string; // 公式 + organTree?: string; // 树 + organLevel?: string; // 树级别 + dictId?: string; // 字典项 + tech?: string; // 技术口径 + busi?: string; // 业务口径 + isAddRow?: 'Y' | 'N'; +} +export interface ParamsDefs { + /** ID */ + id: string; + filedName: string; + /** 参数字段标签 */ + label: string; + /** 参数字段类型 */ + fieldType: string; + /** 参数默认值 */ + defaultVal: string | number; + /** @deprecated */ + defaulVal: string | number; + /** 测试运行使用的值 */ + testVal: string | number; +} +export interface GroupDeftsValues { + label: string; // 标签 + value: string; // 值 +} +/** + * 分组字段信息 + */ +export interface GroupDeftsItem { + /**字段ID */ + fieldId?: string; + /** 字段ID */ + itemId?: string; + /** 字段类型 */ + fieldType?: string; + /** 字段名称 */ + fieldName?: string; + /** 字段注释 */ + remarks?: string; + /** 字段显示名称 */ + fullName?: string; + /** 表名 */ + tableName?: string; + /** 函数名称 */ + functionName?: string; + /** 分组位置 */ + groupType?: string; + /** 字典ID */ + dictId?: string; + /** 是否筛选项 */ + filter?: boolean; + /** 筛选值全部集合 */ + values?: GroupDeftsValues[]; + /** 已选中筛选值集合 */ + checkedValues?: string[]; +} +/** + * 分组字段 + */ +export interface GroupDefts { + rows: GroupDeftsItem[] | null; // 行 + columns: GroupDeftsItem[] | null; // 列 + publicdimension: GroupDeftsItem[] | null; // 公共维度 + metric: GroupDeftsItem[] | null; // 度量 +} +export interface Map { + [index: string]: string; +} +/** 源表(逗号相隔)、目标表数据源、目标表 */ +export interface Rule { + type: string; // 是否新增/更新 + reportName: string; // 报表名称 + ruleCode: string; // 规则编码 + ruleName: string; // 规则名称 + checknode: string; // + startDate: string; // 启用日期 + failDate: string; // 失效日期 + organLevel: string[] | string; // 卷数 + ruleCycle: string; // 规则周期 + ruleStatus: string; // 是否有效 + description: string; // 规则描述 + organCode: string; // + /** 目标数据源schema */ + targetSchema: string; +} +export interface Procedure { + /** 名称 */ + name?: string; + /** 内容 */ + content?: string; +} +export interface TargetRuleState { + /** 版本号 */ + version: string; + /** 是否只读 */ + readOnly?: boolean; + /** 规则编码 */ + ruleCode: string; + /** 数据源 */ + dataSourceId: string; + /** 数据库 */ + schema: string; + /** 表关联关系 */ + queryDefs: QueryDefs[]; + /** 字段信息 */ + fieldDefs: FieldDefs[]; + /** 参数配置 */ + paramsDefs: ParamsDefs[]; + /** 分组字段 */ + groupDefts: GroupDefts; + /** 过滤条件配置 */ + conditionDefts: ConditionDefts[]; + /** 过滤条件sql */ + sql?: string; + /** 存储过程 */ + procedure?: Procedure; + /** sql */ + pureSql?: string; + /** 当前获取焦点的表(前端) */ + focusingQueryDefs: string | number; + /** 基本属性 */ + rule: Rules; + /** 映射物理列名 */ + columnMap: Map; + /** 映射item_id的值 */ + rowMap: Map; // + /** */ + columnMapKeys: string[]; + /** 没有行的时候填写的固定指标ID */ + fixedItemId: string | null; + /** 存储规则编号 */ + storageRuleId: string | null; + /** 指标集编号 */ + reportId: string | null; +} +export const useTargetRuleStore = defineStore('targetRule',{ + state:():TargetRuleState =>({ + columnMap:{},// 列配置 + columnMapKeys:[],//列配置对应的key项 + conditionDefts:[], + dataSourceId:"",//当前数据源id--系统编码 + fieldDefs:[],// + fixedItemId:"",// + focusingQueryDefs:0, + groupDefs:{}, + paramsDefs:[], + procedure:{}, + pureSql:"", + queryDefs:[], + reportId:null, + rowMap:{}, + rule:{ + id: "",/** ID */ + queryDefsId: "",/** 表信息ID */ + fieldId:"",/** 字段名称 */ + fullId:"",/** 表信息ID + 字段名称 */ + alia: "",/** 别名 */ + type: "",/** 字段类型 */ + consy: "",/** 表达式 */ + funName: "",/** 函数名 */ + value: "",/** 表达式里的值 */ + regexp: "",/** 正则 */ + }, + ruleCode:"", + schema:"", + sql:"", + storageRuleId:null, + version:"", + }), + getters:{ + + }, + actions:{ + + } + +}) +export const useTargetRuleStoreWithOut = () => { + return useTargetRuleStore(store) +} + + diff --git a/src/views/IndexProcess/ProcedureRule/components/ProcedureConfig.vue b/src/views/IndexProcess/ProcedureRule/components/ProcedureConfig.vue index d3e0962..0b3ddf3 100644 --- a/src/views/IndexProcess/ProcedureRule/components/ProcedureConfig.vue +++ b/src/views/IndexProcess/ProcedureRule/components/ProcedureConfig.vue @@ -3,7 +3,8 @@ import { ElCol,ElForm, ElFormItem, ElSelect, ElOption, ElInput } from 'element-p import { PropType,ref,reactive, watch,onMounted } from 'vue' import { useValidator } from '@/hooks/web/useValidator' import * as monaco from 'monaco-editor'; - +import { format } from 'sql-formatter'; +import { getTableList } from '@/api/dataManage/dataSourceManage/index' const { required } = useValidator() const props = defineProps({ currentRow: { @@ -81,6 +82,16 @@ let sqlInfo = reactive({ const sqlEditor = ref(null); let editorInstance = null; +//获取数据源列表 +const getDataSourceList = async()=>{ + const res = await getTableList({}) + console.log(res,"获取res信息"); + if(res.head.code == '0'){//说明获取成功 + sqlInfo.dataSourceList = res.body.list; + } +} + +//初始化编辑器实例 const InitEditorInstance = () => { editorInstance = monaco.editor.create(sqlEditor.value, { value: sqlInfo.pureSql, @@ -95,22 +106,34 @@ const InitEditorInstance = () => { }); } onMounted(()=>{ - { - InitEditorInstance(); -} + InitEditorInstance();//初始化编辑器实例 + getDataSourceList();//获取数据源列表 }) //格式化SQL const formatterSql = ()=>{ - + const model = editorInstance.getModel(); + if (model) { + const formattedSql = format(model.getValue()); + model.setValue(formattedSql); + } } +//提交当前界面的信息 +const submit = () =>{ + const model = editorInstance.getModel(); + sqlInfo.pureSql = model.getValue(); + return sqlInfo +} +defineExpose({ + submit +}) \ No newline at end of file diff --git a/src/views/dataset/IndexSearchServiceMs/components/DataDillingByOrgan.vue b/src/views/dataset/IndexSearchServiceMs/components/DataDillingByOrgan.vue new file mode 100644 index 0000000..ef51e52 --- /dev/null +++ b/src/views/dataset/IndexSearchServiceMs/components/DataDillingByOrgan.vue @@ -0,0 +1,92 @@ + + + + \ No newline at end of file diff --git a/src/views/dataset/IndexSearchServiceMs/components/DrillingOrAnalysis.vue b/src/views/dataset/IndexSearchServiceMs/components/DrillingOrAnalysis.vue new file mode 100644 index 0000000..c0c77eb --- /dev/null +++ b/src/views/dataset/IndexSearchServiceMs/components/DrillingOrAnalysis.vue @@ -0,0 +1,85 @@ + + + + \ No newline at end of file diff --git a/src/views/dataset/IndexSearchServiceMs/components/TrendAnalysis.vue b/src/views/dataset/IndexSearchServiceMs/components/TrendAnalysis.vue new file mode 100644 index 0000000..0956a48 --- /dev/null +++ b/src/views/dataset/IndexSearchServiceMs/components/TrendAnalysis.vue @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/views/dataset/RepSetRule/RepSetRule.vue b/src/views/dataset/RepSetRule/RepSetRule.vue index 5b3482b..d241d52 100644 --- a/src/views/dataset/RepSetRule/RepSetRule.vue +++ b/src/views/dataset/RepSetRule/RepSetRule.vue @@ -20,8 +20,8 @@ import { ContentWrap } from '@/components/ContentWrap' import Write from './components/Write.vue' import { Dialog } from '@/components/Dialog' import { getWidth } from '@/utils'; -import Detail from './components/Detail.vue' import { Upload } from '@/components/Upload' +import { RULE_TYPE_LIST } from '@/views/IndexProcess/constants' const { t } = useI18n() @@ -230,6 +230,7 @@ const action = async (row: TableData, type: string) => { } } let RuleType = ref(''); + const AddAction = (ruleType: string) => { RuleType.value = ruleType; dialogTitle.value = t('tableDemo.add') @@ -318,12 +319,10 @@ const exportExcel = async () => { > \ No newline at end of file diff --git a/src/views/dataset/RepSetRule/components/Detail.vue b/src/views/dataset/RepSetRule/components/Detail.vue deleted file mode 100644 index a986bbf..0000000 --- a/src/views/dataset/RepSetRule/components/Detail.vue +++ /dev/null @@ -1,91 +0,0 @@ - - -