修改指标加工的功能,需要下载格式化sql功能npm install sql-formatter

main
于阔 9 months ago
parent bbf9eb7bb7
commit 4a98e265a3

@ -3,7 +3,7 @@ import type { TableData } from './types';
/** 获取表格数据 */ /** 获取表格数据 */
export const getTableList = (data: any) => { 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 });
}; };
/** 批量删除 */ /** 批量删除 */

@ -10,7 +10,8 @@ const props = defineProps({
modelValue: propTypes.bool.def(false), modelValue: propTypes.bool.def(false),
title: propTypes.string.def('Dialog'), title: propTypes.string.def('Dialog'),
fullscreen: propTypes.bool.def(true), 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(() => { const getBindValue = computed(() => {
@ -25,10 +26,10 @@ const getBindValue = computed(() => {
return obj return obj
}) })
const isFullscreen = ref(false) let isFullscreen = ref(props.ISFullScreen)
const toggleFull = () => { const toggleFull = () => {
isFullscreen.value = !unref(isFullscreen) isFullscreen.value = !isFullscreen.value;
} }
const dialogHeight = ref(isNumber(props.maxHeight) ? `${props.maxHeight}px` : props.maxHeight) const dialogHeight = ref(isNumber(props.maxHeight) ? `${props.maxHeight}px` : props.maxHeight)

@ -1,30 +1,32 @@
<template> <template>
<div class="fixedToolBar"> <div v-loading="loading">
<ElDropdown placement="bottom"> <div class="fixedToolBar">
<!-- 其中包含的功能有分页页数跳转文件下载 --> <ElDropdown placement="bottom">
<i class="fa fa-download cursor-pointer download" hover-color="var(--el-color-primary)"></i> <!-- 其中包含的功能有分页页数跳转文件下载 -->
<template #dropdown> <i class="fa fa-download cursor-pointer download" hover-color="var(--el-color-primary)"></i>
<ElDropdownMenu> <template #dropdown>
<ElDropdownItem @click="downloadFile('pdf')">PDF</ElDropdownItem> <ElDropdownMenu>
<ElDropdownItem @click="downloadFile('word')">WORD</ElDropdownItem> <ElDropdownItem @click="downloadFile('pdf')">PDF</ElDropdownItem>
</ElDropdownMenu> <ElDropdownItem @click="downloadFile('word')">WORD</ElDropdownItem>
</template> </ElDropdownMenu>
</ElDropdown> </template>
</div> </ElDropdown>
<div class="pdf-viewer" :loading="loading">
<div class="sidebar">
<ul>
<li v-for="(page,pageIndex) in pagesInfo" :key="page.number" @click="navigateToPage(page.number)">
<a>
<img :src="page.thumbnail" alt="Page Thumbnail" :class="pageIndex===currentPage?'thumbnail active':'thumbnail'" />
<span>{{ pageIndex+1 }}</span>
</a>
</li>
</ul>
</div> </div>
<div class="pdf-container" @scroll="handleScroll"> <div class="pdf-viewer">
<!-- <input type="file" @change="handleFileChange" accept="application/pdf" /> --> <div class="sidebar">
<div ref="pdfContainer" class="pdf-pages"></div> <ul>
<li v-for="(page,pageIndex) in pagesInfo" :key="page.number" @click="navigateToPage(page.number)">
<a>
<img :src="page.thumbnail" alt="Page Thumbnail" :class="pageIndex===currentPage?'thumbnail active':'thumbnail'" />
<span>{{ pageIndex+1 }}</span>
</a>
</li>
</ul>
</div>
<div class="pdf-container" @scroll="handleScroll">
<!-- <input type="file" @change="handleFileChange" accept="application/pdf" /> -->
<div ref="pdfContainer" class="pdf-pages"></div>
</div>
</div> </div>
</div> </div>
</template> </template>
@ -166,9 +168,9 @@ const TurnBlobForRender = async (data) => {
await generateThumbnails(); await generateThumbnails();
renderAllPages(); renderAllPages();
currentPage.value = 0;// currentPage.value = 0;//
let loading = ref(false); loading.value = false;
} catch (error) { } catch (error) {
let loading = ref(false); loading.value = false;
console.error('Error loading PDF:', error); console.error('Error loading PDF:', error);
} }
}; };
@ -179,7 +181,7 @@ const TurnBlobForRender = async (data) => {
}; };
// //
const fetchDocFile = async () => { const fetchDocFile = async () => {
let loading = ref(true); loading.value = true;
// API DOCX ArrayBuffer // API DOCX ArrayBuffer
const response = await queryFileFlowRepTemplateApi(params); const response = await queryFileFlowRepTemplateApi(params);
const { data, headers } = response; const { data, headers } = response;
@ -195,7 +197,7 @@ const fetchDocFile = async () => {
ElMessage.error(downLoadErrorMsg['1003']); ElMessage.error(downLoadErrorMsg['1003']);
break; break;
} }
let loading = ref(false); loading.value = false;
return; return;
} }
BlobFile.value = response; BlobFile.value = response;
@ -217,7 +219,6 @@ const handleFileChange = async (event) => {
} }
const fileReader = new FileReader(); const fileReader = new FileReader();
fileReader.onload = async (e) => { fileReader.onload = async (e) => {
console.log(e,"文件信息");
const typedArray = new Uint8Array(e.target.result); const typedArray = new Uint8Array(e.target.result);
try { try {
pdfDocument.value = await pdfjsLib.getDocument({ data: typedArray }).promise; pdfDocument.value = await pdfjsLib.getDocument({ data: typedArray }).promise;

@ -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)
}

@ -3,7 +3,8 @@ import { ElCol,ElForm, ElFormItem, ElSelect, ElOption, ElInput } from 'element-p
import { PropType,ref,reactive, watch,onMounted } from 'vue' import { PropType,ref,reactive, watch,onMounted } from 'vue'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
import { format } from 'sql-formatter';
import { getTableList } from '@/api/dataManage/dataSourceManage/index'
const { required } = useValidator() const { required } = useValidator()
const props = defineProps({ const props = defineProps({
currentRow: { currentRow: {
@ -81,6 +82,16 @@ let sqlInfo = reactive({
const sqlEditor = ref(null); const sqlEditor = ref(null);
let editorInstance = 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 = () => { const InitEditorInstance = () => {
editorInstance = monaco.editor.create(sqlEditor.value, { editorInstance = monaco.editor.create(sqlEditor.value, {
value: sqlInfo.pureSql, value: sqlInfo.pureSql,
@ -95,22 +106,34 @@ const InitEditorInstance = () => {
}); });
} }
onMounted(()=>{ onMounted(()=>{
{ InitEditorInstance();//
InitEditorInstance(); getDataSourceList();//
}
}) })
//SQL //SQL
const formatterSql = ()=>{ 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
})
</script> </script>
<template> <template>
<ElForm :model="sqlInfo" label-width="auto" :rules="rules"> <ElForm :model="sqlInfo" label-width="auto" :rules="rules">
<ElRow> <ElRow>
<ElCol :span="12"> <ElCol :span="12">
<ElFormItem label="数据源"> <ElFormItem label="数据源" style="margin-left:20px;">
<ElSelect v-model="sqlInfo.schema" placeholder="请选择数据源"> <ElSelect v-model="sqlInfo.schema" placeholder="请选择数据源">
<el-option :label="item.dsname" :value="item.dscode" :key="item.dscode" v-for="item in sqlInfo.dataSourceList" /> <el-option :label="item.dsname" :value="item.dscode" :key="item.dscode" v-for="item in sqlInfo.dataSourceList" />
</ElSelect> </ElSelect>

@ -1,12 +1,41 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { ElTabs,ElTabPane } from 'element-plus'; import { ref } from 'vue';
import { ElTabs,ElTabPane,ElMessage } from 'element-plus';
import ProcedureConfig from '@/views/IndexProcess/ProcedureRule/components/ProcedureConfig.vue'; import ProcedureConfig from '@/views/IndexProcess/ProcedureRule/components/ProcedureConfig.vue';
import SetParams from './components/SetParams.vue'; import SetParams from './components/SetParams.vue';
import BasicInfo from './components/BasicInfo.vue'; import BasicInfo from './components/BasicInfo.vue';
import { saveRepSetRuleApi } from '@/api/dataset/RepSetRule/index'
//sql
const procedureConfig = ref<ComponentRef<typeof ProcedureConfig>>();//sql
const setParams = ref<ComponentRef<typeof SetParams>>();//
const basicInfo = ref<ComponentRef<typeof BasicInfo>>();//
const procedureConfigRef = ref(procedureConfig);
const setParamsRef = ref(setParams);
const basicInfoRef = ref(basicInfo);
let loading = ref(false);
const saveSqlRule = async()=>{
loading.value = true;
const procedureConfigSubmit = await procedureConfigRef.value?.submit();
const setParamsSubmit = await setParamsRef.value?.submit();
const basicInfoSubmit = await basicInfoRef.value?.submit();
saveRepSetRuleApi(Object.assign(procedureConfigSubmit,setParamsSubmit,basicInfoSubmit)).then(res=>{
loading.value = false;
if(res.head.code == '0'){
ElMessage.success('保存成功');
}else{
ElMessage.error(res.head.message);
}
}).catch(err=>{
loading.value = false;
ElMessage.error('保存失败');
})
}
</script> </script>
<template> <template>
<ContentWrap> <ContentWrap v-loading="loading">
<ElTabs tab-position="left" style="height: 100%;"> <ElTabs tab-position="left" style="height: 100%;">
<ElTabPane label="SQL"> <ElTabPane label="SQL">
<ProcedureConfig ref="procedureConfig" rule-type="SqlRule" /> <ProcedureConfig ref="procedureConfig" rule-type="SqlRule" />
@ -15,7 +44,7 @@
<SetParams ref="setParams" /> <SetParams ref="setParams" />
</ElTabPane> </ElTabPane>
<ElTabPane label="基本信息"> <ElTabPane label="基本信息">
<BasicInfo ref="basicInfo" /> <BasicInfo ref="basicInfo" @save-sql-rule="saveSqlRule" />
</ElTabPane> </ElTabPane>
</ElTabs> </ElTabs>
</ContentWrap> </ContentWrap>

@ -3,8 +3,7 @@ import { Form, FormSchema } from '@/components/Form'
import { useForm } from '@/hooks/web/useForm' import { useForm } from '@/hooks/web/useForm'
import { PropType,ref,reactive, watch } from 'vue' import { PropType,ref,reactive, watch } from 'vue'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
import { ElDialog } from 'element-plus' import {RULE_CYCLE_LIST,RULE_IS_VALID_LIST} from '@/views/IndexProcess/constants'
import {vue3CronPlus} from '@/views/vue3-cron-plus/index'
const { required } = useValidator() const { required } = useValidator()
const props = defineProps({ const props = defineProps({
@ -13,32 +12,90 @@ const props = defineProps({
default: () => null default: () => null
} }
}) })
let showCron = ref(false);
let NewCornData = "";//corn
const formSchema = reactive<FormSchema[]>([ const formSchema = reactive<FormSchema[]>([
{ {
field: 'cron', field: 'ruleCode',
label: '定时器信息', label: '规则编码',
component: 'Input', component: 'Input',
colProps: { componentProps:{
span: 24 placeholder: '请输入规则编码',
showWordLimit: true,
}
},
{
field: 'ruleName',
label: '规则名称',
component: 'Input',
componentProps:{
placeholder: '请输入规则编码',
showWordLimit: true,
}
},
{
field: 'startDate',
label: '启用日期',
component: 'DatePicker',
colProps:{
span: 12
}, },
componentProps:{ componentProps:{
value:"", valueFormat: 'YYYYMMDD',
on:{ style: {
click:()=>{ width: '100%'
NewCornData = formSchema[0].value;
showCron.value = true;
}
} }
} }
}, },
{
field: 'failDate',
label: '失效日期',
component: 'DatePicker',
colProps:{
span: 12
},
componentProps:{
valueFormat: 'YYYYMMDD',
style: {
width: '100%'
}
}
},
{
field: 'ruleCycle',
label: '规则周期',
component: 'Select',
componentProps:{
options: RULE_CYCLE_LIST
}
},
{
field: 'ruleStatus',
label: '是否有效',
component: 'Select',
componentProps:{
options: RULE_IS_VALID_LIST
}
},
{
field: 'description',
label: '规则描述',
component: 'Input',
colProps:{
span: 24
},
componentProps: {
type: 'textarea',
},
},
]) ])
const rules = reactive({ const rules = reactive({
cron:[required()], ruleCode:[required()],
ruleName:[required()],
startDate:[required()],
failDate:[required()],
ruleCycle:[required()],
ruleStatus:[required()],
}) })
const { formRegister, formMethods } = useForm() const { formRegister, formMethods } = useForm()
@ -51,7 +108,6 @@ const submit = async () => {
}) })
if (valid) { if (valid) {
const formData = await getFormData(); const formData = await getFormData();
formData.cron = formSchema[0].value;
return formData return formData
} }
} }
@ -67,39 +123,30 @@ watch(
immediate: true immediate: true
} }
) )
//
const changeCron = (corn)=>{ const emit = defineEmits(['saveSqlRule']);
formSchema[0].value = corn.toString(); const save = ()=>{
formSchema[0].componentProps.value = corn.toString(); emit('saveSqlRule');
if(formSchema[0].value != '[object Event]'){
NewCornData = formSchema[0].value
}
}
const closeDialog = ()=>{
if(NewCornData != formSchema[0].value){
formSchema[0].value = NewCornData;
formSchema[0].componentProps.value = NewCornData;
}
showCron.value = false;
} }
defineExpose({ defineExpose({
submit submit
}) })
</script> </script>
<template> <template>
<Form :rules="rules" @register="formRegister" :schema="formSchema" /> <Form :rules="rules" @register="formRegister" :schema="formSchema" class="sqlRuleForm" />
<ElDialog v-model="showCron"> <div class="operateSQLR">
<vue3CronPlus <ElButton type="primary" @click="save"></ElButton>
i18n="cn" <ElButton @click="formRegister"></ElButton>
@change="changeCron" </div>
@close="closeDialog"
max-height="300px"
/>
</ElDialog>
</template> </template>
<style scoped> <style scoped>
.vue3-cron-plus-container>>>.language{ .sqlRuleForm{
top:40px !important; width:800px;
} margin: 20px auto;
}
.operateSQLR{
text-align: center;
}
</style> </style>

@ -2,10 +2,8 @@
<script setup lang="tsx"> <script setup lang="tsx">
import { Form, FormSchema } from '@/components/Form' import { Form, FormSchema } from '@/components/Form'
import { useForm } from '@/hooks/web/useForm' import { useForm } from '@/hooks/web/useForm'
import { PropType,ref,reactive, watch,unref } from 'vue' import { PropType,ref,reactive, watch,computed } from 'vue'
import { useValidator } from '@/hooks/web/useValidator' import {FIELD_TYPES_LIST} from '@/views/IndexProcess/constants'
const { required } = useValidator()
const props = defineProps({ const props = defineProps({
currentRow: { currentRow: {
type: Object as PropType<any>, type: Object as PropType<any>,
@ -13,50 +11,84 @@ const props = defineProps({
} }
}) })
const tableColumns = reactive<ElTableColumn[]>([ const formSchema = reactive<FormSchema[]>([
{
field: 'selection',
type: 'selection',
width: 50,
},
{ {
field: 'index', field: 'index',
label: '序号', label: '序号',
fixed:"left", hidden: true
width: 120,
}, },
{ {
field: 'jId', field: 'filedName',
label: '参数名称', label: '参数名称',
component: 'Input',
colProps:{
span:24
},
componentProps:{
placeholder:'请输入参数名称',
on:{
input:()=>editParams()
}
}
}, },
{ {
field: 'jId', field: 'label',
label: '参数注释', label: '参数注释',
component: 'Input',
colProps:{
span:24
},
componentProps:{
placeholder:'请输入参数注释',
on:{
input:()=>editParams()
}
}
}, },
{ {
field: 'jId', field: 'defaultVal',
label: '参数默认值', label: '参数默认值',
component: 'Input',
colProps:{
span:24
},
componentProps:{
placeholder:'请输入参数默认值',
on:{
input:()=>editParams()
}
}
}, },
{ {
field: 'jId', field: 'testVal',
label: '测试运行默认值', label: '测试运行默认值',
component: 'Input',
colProps:{
span:24
},
componentProps:{
placeholder:'请输入测试运行默认值',
on:{
input:()=>editParams()
}
}
}, },
{ {
field: 'jId', field: 'fieldType',
label: '字段类型' label: '字段类型',
} component: 'Select',
]) componentProps: {
options: FIELD_TYPES_LIST,
const formSchema = reactive<FormSchema[]>([ onChange:()=>editParams()
},
colProps:{
span:24
}
},
]) ])
const rules = reactive({
})
const { formRegister, formMethods } = useForm() const { formRegister, formMethods } = useForm()
const { setValues,getFormData, getElFormExpose } = formMethods const { setValues,getFormData } = formMethods
watch( watch(
() => props.currentRow, () => props.currentRow,
(currentRow) => { (currentRow) => {
@ -70,20 +102,94 @@ watch(
) )
let searchParam = reactive({ let searchParam = reactive({
paramsType:"code",// paramsType:"filedName",//
searchText:"",// searchText:"",//
}) })
let filterList = reactive([]);// let filterList = reactive([]);//
let filterListTemp = reactive([]);//Temp
let idsList = reactive([]);//
let ColumnStatus = ref(false);
// //
const onSelectionChange = (ids)=>{ const onSelectionChange = (ids)=>{
console.log(ids,"多选的ids信息");
idsList = ids;
}
//
const handleCurrentChange = (row)=>{
console.log(row,"当前点击的行信息");
} }
// //
const handleAddParams = ()=>{ const handleAddParams = ()=>{
const addNewRow = {
index:filterList.length+1,
filedName:`EXP${filterList.length+1}`,//
label:"参数名",//
defaultVal:"",//
testVal:"",//
fieldType:"",//
}
filterList.push(addNewRow);
console.log(filterList);
filterListTemp = filterList;
}
//
const handleRowClick = (row)=>{
setValues(row);
ColumnStatus.value = true
}
//
const editParams = async ()=>{
const formData = await getFormData();
filterList[formData.index-1] = Object.assign(filterList[formData.index-1],formData);
filterListTemp = filterList;
}
//
const deleteParamsList = ()=>{
if(idsList.length == 0)return;
//table
const indexList = idsList.map(item=>{
return item.filedName;
})
indexList.forEach(list=>{
filterList.splice(
filterListTemp.findIndex(item => item.filedName == list),
1
);
})
filterListTemp = filterList;
idsList = [];
ColumnStatus.value = false;
}
//list
const filterTableList = ()=>{
if(!searchParam.searchText){
filterList = filterListTemp;
return;
}
//searchParam.searchTextsearchParam.paramsType
switch(searchParam.paramsType){
case 'filedName'://
filterList = filterListTemp.filter(item=>{
return item.filedName.indexOf(searchParam.searchText)>=0;
})
break;
case 'label'://
filterList = filterListTemp.filter(item=>{
return item.label.indexOf(searchParam.searchText)>=0;
})
break;
}
console.log(filterList);
ColumnStatus.value = false;
} }
//
const submit = ()=>{
return {paramsDefs:filterList};
}
defineExpose({
submit
})
</script> </script>
<template> <template>
@ -91,17 +197,18 @@ const handleAddParams = ()=>{
<ElContainer> <ElContainer>
<ElHeader> <ElHeader>
<ElButton type="success" @click="handleAddParams"></ElButton> <ElButton type="success" @click="handleAddParams"></ElButton>
<ElButton type="danger">批量删除</ElButton> <ElButton type="danger" @click="deleteParamsList" :disabled="idsList.length==0">批量删除</ElButton>
<ElInput <ElInput
v-model="searchParam.searchText" v-model="searchParam.searchText"
placeholder="按参数名称或注释搜索" placeholder="按参数名称或注释搜索"
clearable clearable
style="margin-left:15px; width: 300px" style="margin-left:15px; width: 300px;"
@input="filterTableList"
> >
<template #prepend> <template #prepend>
<el-select v-model="searchParam.paramsType" placeholder="Select" style="width: 115px"> <el-select v-model="searchParam.paramsType" placeholder="Select" style="width: 115px">
<el-option label="参数名称" value="code" /> <el-option label="参数名称" value="filedName" />
<el-option label="参数注释" value="name" /> <el-option label="参数注释" value="label" />
</el-select> </el-select>
</template> </template>
</ElInput> </ElInput>
@ -109,30 +216,34 @@ const handleAddParams = ()=>{
<ElMain> <ElMain>
<!-- 参数配置字段信息的表格 --> <!-- 参数配置字段信息的表格 -->
<ElTable <ElTable
align="center" stripe
headerAlign="center" headerAlign="center"
:data="filterList" :data="filterList"
@selection-change="onSelectionChange" @selection-change="onSelectionChange"
@row-click="handleRowClick"
style="width:100%;" style="width:100%;"
height="calc(100% - 50px)" height="calc(100% - 50px)"
@current-change="handleCurrentChange"
> >
<ElTableColumn fixed type="selection" width="55" /> <ElTableColumn fixed type="selection" width="40" />
<ElTableColumn width="{60}" fixed label="序号" align="center" /> <ElTableColumn width="60" fixed label="序号" type="index" />
<ElTableColumn prop="filedName" label="参数名称" /> <ElTableColumn width="150" prop="filedName" label="参数名称" />
<ElTableColumn prop="label" label="参数注释" /> <ElTableColumn width="150" prop="label" label="参数注释" />
<ElTableColumn prop="defaultVal" label="参数默认值" /> <ElTableColumn width="150" prop="defaultVal" label="参数默认值" />
<ElTableColumn prop="testVal" label="测试运行默认值" /> <ElTableColumn prop="testVal" label="测试运行默认值" />
<ElTableColumn prop="fieldType" label="字段类型" /> <ElTableColumn width="120" label="字段类型">
<template #default="scope">
<span>{{ FIELD_TYPES_LIST.filter(item=>{return item.value == scope.row.fieldType})[0].label }}</span>
</template>
</ElTableColumn>
</ElTable> </ElTable>
</ElMain> </ElMain>
</ElContainer> </ElContainer>
<ElAside width="10px"> <ElAside width="250px" style="border-left:1px solid #ddd;height:100vh;">
<Form :rules="rules" @register="formRegister" :schema="formSchema" /> <Form @register="formRegister" :schema="formSchema" labelPosition="top" v-show="ColumnStatus" />
</ElAside> </ElAside>
</ElContainer> </ElContainer>
</template> </template>
<style scoped> <style scoped>
.vue3-cron-plus-container>>>.language{
top:40px !important;
}
</style> </style>

@ -0,0 +1,65 @@
//指标加工规则的类型信息
export const RULE_TYPE_LIST = [
// {
// value: '0',
// label: '指标规则',
// name:'ProcedureRule'
// },
{
value: '1',
label: 'SQL规则',
name:'SqlRule'
},
// {
// value: '2',
// label: '存储过程规则',
// name:'PureSqlRule'
// }
]
//规则周期
export const RULE_CYCLE_LIST = [
{
value: '0',
label: '日'
},
{
value: '1',
label: '旬'
},
{
value: '2',
label: '月'
},
{
value: '3',
label: '季'
},
{
value: '4',
label: '半年'
},
{
value: '5',
label: '年'
}
]
//选择规则是否有效
export const RULE_IS_VALID_LIST = [
{
value: '0',
label: '是'
},
{
value: '1',
label: '否'
}
]
// 字段类型字典项
export const FIELD_TYPES_LIST = [
{ label: '报表日期', value: 'REPORT_DATE' },
{ label: '机构', value: 'ORGAN_ID' },
{ label: '其他', value: '' },
];

@ -24,6 +24,8 @@ import { getWidth } from '@/utils';
import { Upload } from '@/components/Upload' import { Upload } from '@/components/Upload'
import { saveRepDataProblemApi } from '@/api/reporting/RepDataProblem/RepDataProblem' import { saveRepDataProblemApi } from '@/api/reporting/RepDataProblem/RepDataProblem'
import {useRoute} from "vue-router" import {useRoute} from "vue-router"
import RepSetRuleWrite from '@/views/dataset/RepSetRule/components/Write.vue'
import { RULE_TYPE_LIST } from '@/views/IndexProcess/constants'
const route = useRoute(); const route = useRoute();
const pageQuery = ref(route || null); const pageQuery = ref(route || null);
@ -199,22 +201,41 @@ const action = async (row: TableData, type: string) => {
/** 添加指标加工规则**/ /** 添加指标加工规则**/
let RuleConfigInfo = reactive({
dialogVisible: false,//
dialogTitle: '',//
currentRow: {},//
actionType:'add',//
RuleType: ''//
})
const addRuleConfig = async () => { const addRuleConfig = async () => {
const ruleConfig = unref(ruleConfigRef) const ruleConfig = unref(ruleConfigRef)
const formData = await ruleConfig?.submit() const formData = await ruleConfig?.submit();
if (formData) { const rule = RULE_TYPE_LIST.filter(ruleItem=>{
saveLoading.value = true return ruleItem.value === formData.ruleType;
const res = await saveRepDataProblemApi(formData) })[0];
.catch(() => {}) console.log(formData,"formData信息");
.finally(() => { if(formData){
saveLoading.value = false dialogVisible.value = false;
}) RuleConfigInfo.dialogVisible = true;
if (res) { RuleConfigInfo.dialogTitle = `配置${rule.label}`;
dialogVisible.value = false RuleConfigInfo.RuleType = rule.name;
currentPage.value = 1 RuleConfigInfo.actionType = 'add';
getList()
}
} }
// if (formData) {
// saveLoading.value = true
// const res = await saveRepDataProblemApi(formData)
// .catch(() => {})
// .finally(() => {
// saveLoading.value = false
// })
// if (res) {
// dialogVisible.value = false
// currentPage.value = 1
// getList()
// }
// }
} }
const AddAction = () => { const AddAction = () => {
dialogTitle.value = t('tableDemo.add') dialogTitle.value = t('tableDemo.add')
@ -319,7 +340,7 @@ const exportExcel = async () => {
:current-row="currentRow" :current-row="currentRow"
:action-type="actionType" :action-type="actionType"
/> />
<RuleConfig v-if="actionType === 'ruleconfig'" /> <RuleConfig ref="ruleConfigRef" v-if="actionType === 'ruleconfig'" />
<template #footer> <template #footer>
<ElButton v-if="actionType == 'edit'" type="primary" :loading="saveLoading" @click="save"> <ElButton v-if="actionType == 'edit'" type="primary" :loading="saveLoading" @click="save">
{{ t('dialogDemo.save') }} {{ t('dialogDemo.save') }}
@ -330,4 +351,10 @@ const exportExcel = async () => {
<ElButton @click="dialogVisible = false">{{ t('dialogDemo.close') }}</ElButton> <ElButton @click="dialogVisible = false">{{ t('dialogDemo.close') }}</ElButton>
</template> </template>
</Dialog> </Dialog>
<Dialog v-model="RuleConfigInfo.dialogVisible" :title="RuleConfigInfo.dialogTitle" :ISFullScreen="true" style="overflow: hidden;">
<RepSetRuleWrite
:current-row="RuleConfigInfo.currentRow"
:action-type="RuleConfigInfo.actionType"
:rule-type="RuleConfigInfo.RuleType" />
</Dialog>
</template> </template>

@ -3,7 +3,7 @@ import { Form, FormSchema } from '@/components/Form'
import { useForm } from '@/hooks/web/useForm' import { useForm } from '@/hooks/web/useForm'
import { PropType, reactive, watch } from 'vue' import { PropType, reactive, watch } from 'vue'
import { useValidator } from '@/hooks/web/useValidator' import { useValidator } from '@/hooks/web/useValidator'
// import { getWorkFlowVisiableButton } from '@/api/csck/CsckFlow'; import { RULE_TYPE_LIST } from '@/views/IndexProcess/constants'
const { required } = useValidator() const { required } = useValidator()
@ -23,20 +23,7 @@ const formSchema = reactive<FormSchema[]>([
label: '加工规则类型:', label: '加工规则类型:',
component: 'Select', component: 'Select',
componentProps:{ componentProps:{
options: [ options: RULE_TYPE_LIST
{
label: '指标规则',
value: '0'
},
{
label: 'SQL规则',
value: '1'
},
{
label: '存储过程规则',
value: '2'
}
]
}, },
value: '1' value: '1'
} }
@ -55,7 +42,8 @@ const submit = async () => {
console.log(err) console.log(err)
}) })
if (valid) { if (valid) {
const formData = await getFormData() const formData = await getFormData();
console.log(formData,"formData in RuleConfig");
return formData return formData
} }
} }

@ -30,8 +30,8 @@ let frequency_param_LIST = ref([]);
// //
const getDictInfoList = async ()=>{ const getDictInfoList = async ()=>{
const res = await getIndexType({ paramName: 'frequency_param', systemCode: 'ordb' }); const res = await getIndexType({ paramName: 'frequency_param', systemCode: 'ordb' });
frequency_param_LIST.value = transfDictList(res.body.result); frequency_param_LIST.value = transfDictList(res.body.result);
} }
getDictInfoList(); getDictInfoList();
@ -119,13 +119,13 @@ const tableColumns = reactive<TableColumn[]>([
{{ {{
default:()=>{ default:()=>{
return <div> return <div>
<span class="canOperate">{data.row.tCategory}</span> <span class="cursor-pointer">{data.row.tCategory}</span>
</div> </div>
}, },
dropdown:()=>{ dropdown:()=>{
return <ElDropdownMenu> return <ElDropdownMenu>
<ElDropdownItem> <ElDropdownItem>
<div>按机构钻取</div> <div onClick={()=>handleDrillingOrAnalysis(data.row,'DataDillingByOrgan','按机构钻取')}>按机构钻取</div>
</ElDropdownItem> </ElDropdownItem>
<ElDropdownItem> <ElDropdownItem>
<div>趋势分析</div> <div>趋势分析</div>
@ -146,7 +146,7 @@ const tableColumns = reactive<TableColumn[]>([
{{ {{
default:()=>{ default:()=>{
return <div> return <div>
<span>{data.row.tCategory}</span> <span class="cursor-pointer">{data.row.tCategory}</span>
</div> </div>
}, },
dropdown:()=>{ dropdown:()=>{
@ -315,14 +315,24 @@ const onSelectionChange = (selection: TableData[]) => {
const onContextMenu = (row: any, column: any, cell: HTMLTableCellElement, event: Event) => { const onContextMenu = (row: any, column: any, cell: HTMLTableCellElement, event: Event) => {
} }
//使
let drillingandanalysis = reactive({
dialogVisiable:false,//
showTitle:"",//
currentRow:{},//
DrillingType:"",// 'DataDillingByOrgan'|'TrendAnalysis'
})
const handleDrillingOrAnalysis = (row: any, type: string,title: string) => {
drillingandanalysis.dialogVisiable = true;
drillingandanalysis.currentRow = row;
drillingandanalysis.DrillingType = type;
drillingandanalysis.showTitle = title;
}
</script> </script>
<template> <template>
<ContentWrap> <ContentWrap>
<Search :schema="searchSchema" @reset="setSearchParams" @search="setSearchParams" /> <Search :schema="searchSchema" @reset="setSearchParams" @search="setSearchParams" />
<Table <Table
:columns="tableColumns" :columns="tableColumns"
v-model:pageSize="pageSize" v-model:pageSize="pageSize"
@ -356,4 +366,8 @@ const onContextMenu = (row: any, column: any, cell: HTMLTableCellElement, event:
<ElButton @click="dialogVisible = false">{{ t('dialogDemo.close') }}</ElButton> <ElButton @click="dialogVisible = false">{{ t('dialogDemo.close') }}</ElButton>
</template> </template>
</Dialog> </Dialog>
<Dialog v-model="drillingandanalysis.dialogVisiable" :title="drillingandanalysis.showTitle">
<DrillingOrAnalysis :current-row="drillingandanalysis.currentRow" :DrillingType="drillingandanalysis.DrillingType" />
</Dialog>
</template> </template>

@ -0,0 +1,92 @@
<!-- 数据分析 -->
<template>
<Table
headerAlign="center"
:columns="tableColumns"
:data="dataList"
:loading="loading"
row-key="randomCode"
lazy
:load="loadJunior"
:tree-props="{ children: 'children', hasChildren: 'hasChildren'}"
/>
</template>
<script lang="tsx" setup>
import {
getRepIndexSearchListApi
} from '@/api/dataset/RepIndexSet'
import { TableData } from '@/api/reporting/RepDataProblem/RepDataProblem/types';
import { useTable } from '@/hooks/web/useTable';
import { Table, TableColumn } from '@/components/Table';
import {reactive, ref, toRaw, unref} from 'vue';
import { randomCode } from '@/utils'
import {ElDropdown,ElDropdownMenu,ElDropdownItem,ElMessage} from 'element-plus';
const { tableRegister, tableState, tableMethods } = useTable({
fetchDataApi: async () => {
const res = await getRepIndexSearchListApi({})
return {
list: res.body.list,
total: res.body.total
}
}
})
const { loading, dataList} = tableState
const { getList } = tableMethods
const tableColumns = reactive<TableColumn[]>([
{
field: 'organName',
label: '机构名称',
},
{
field: 'tCategory',
label: '公式值',
slots:{
default:(data:any)=>{
return <span class="cursor-pointer" style="color:#d9ecff;">{data.row.tCategory}</span>
// return <ElDropdown class="{prefixCls} custom-hover" style="vertical-align: middle;padding:0;" trigger="contextmenu" placement="right">
// {{
// default:()=>{
// return <div>
// <span class="cursor-pointer" style="color:#d9ecff;">{data.row.tCategory}</span>
// </div>
// },
// dropdown:()=>{
// return <ElDropdownMenu>
// <ElDropdownItem>
// <div></div>
// </ElDropdownItem>
// <ElDropdownItem>
// <div></div>
// </ElDropdownItem>
// </ElDropdownMenu>
// }
// }}
// </ElDropdown>
}
}
}
])
/** 查询下级数据加载 */
const loadJunior = async (
row: TableData,
__: any,
resolve: (date: TableData[]) => void
) => {
const res = false;
// const formData = {
// id:row.id
// };
// const res = await getSubTaskListApi(formData);//hasChildrentrue
if (res) {
const data = res?.body?.list;
if(data.length == 0){
ElMessage.success("该任务下没有执行的子任务");
}
resolve(data)
}
}
</script>
<style scoped>
</style>

@ -0,0 +1,85 @@
<!-- 钻取或者分析的弹框 -->
<template>
<ContentWrap>
<!-- 被钻取的指标信息 -->
<ElDivider>被钻取的指标信息</ElDivider>
<Form @register="formRegister" :schema="formSchema" />
<!-- 钻取详情 -->
<ElDivider>钻取详情</ElDivider>
<!-- 按机构钻取 -->
<DataDillingByOrgan :IndexData="IndexData" v-show="DrillingTYPE == 'DataDillingByOrgan'" />
<!-- 趋势分析 -->
</ContentWrap>
</template>
<script lang="tsx" setup>
import { ref,PropType,reactive } from 'vue'
import {ElDivider} from 'element-plus';
import { Form, FormSchema } from '@/components/Form'
import { useForm } from '@/hooks/web/useForm'
import DataDillingByOrgan from './components/DataDillingByOrgan.vue';//
//
const { formRegister, formMethods } = useForm()
const { setValues } = formMethods
const formSchema = reactive<FormSchema[]>([
{
field: 'indexSetName',
label: '指标集',
component: 'Input',
readonly: true,
colProps: {
span: 12,
},
},
{
field: 'indexItemCode',
label: '指标代码',
component: 'Input',
},
{
field: 'indexName',
label: '指标名称',
component: 'Input',
},
{
field: 'targetName',
label: '指标属性',
component: 'Input',
},
{
field: 'organName',
label: '机构',
component: 'Input',
},
{
field: 'paramDate',
label: '报告期',
component: 'Input',
},
{
field: 'cprevDayValue',
label: '指标数值',//
component: 'Input',
}
])
const props = defineProps({
currentRow: {
type: Object as PropType<any>,
default: () => null
},
DrillingType: {
type: String,
default: ''
}
})
const IndexData = reactive(props.currentRow);//
const DrillingTYPE = ref(props.DrillingType);//
setValues(props.currentRow);//
</script>
<style scoped>
</style>

@ -20,8 +20,8 @@ import { ContentWrap } from '@/components/ContentWrap'
import Write from './components/Write.vue' import Write from './components/Write.vue'
import { Dialog } from '@/components/Dialog' import { Dialog } from '@/components/Dialog'
import { getWidth } from '@/utils'; import { getWidth } from '@/utils';
import Detail from './components/Detail.vue'
import { Upload } from '@/components/Upload' import { Upload } from '@/components/Upload'
import { RULE_TYPE_LIST } from '@/views/IndexProcess/constants'
const { t } = useI18n() const { t } = useI18n()
@ -230,6 +230,7 @@ const action = async (row: TableData, type: string) => {
} }
} }
let RuleType = ref(''); let RuleType = ref('');
const AddAction = (ruleType: string) => { const AddAction = (ruleType: string) => {
RuleType.value = ruleType; RuleType.value = ruleType;
dialogTitle.value = t('tableDemo.add') dialogTitle.value = t('tableDemo.add')
@ -318,12 +319,10 @@ const exportExcel = async () => {
> >
<template #buttons> <template #buttons>
<ElDropdown placement="bottom"> <ElDropdown placement="bottom">
<ElButton type="primary">{{ t('tableDemo.add') }}</ElButton> <ElButton type="primary">添加规则</ElButton>
<template #dropdown> <template #dropdown>
<ElDropdownMenu> <ElDropdownMenu>
<ElDropdownItem @click="AddAction('ProcedureRule')"></ElDropdownItem> <ElDropdownItem v-for="item in RULE_TYPE_LIST" :key="item.name" @click="AddAction(item.name)">{{ item.label }}</ElDropdownItem>
<ElDropdownItem @click="AddAction('SqlRule')">SQL</ElDropdownItem>
<ElDropdownItem @click="AddAction('PureSqlRule')"></ElDropdownItem>
</ElDropdownMenu> </ElDropdownMenu>
</template> </template>
</ElDropdown> </ElDropdown>
@ -337,20 +336,12 @@ const exportExcel = async () => {
</Table> </Table>
</ContentWrap> </ContentWrap>
<Dialog v-model="dialogVisible" :title="dialogTitle"> <Dialog v-model="dialogVisible" :title="dialogTitle" :ISFullScreen="true" style="overflow: hidden;">
<Write <Write
v-if="actionType !== 'detail'"
ref="writeRef" ref="writeRef"
:current-row="currentRow" :current-row="currentRow"
:action-type="actionType" :action-type="actionType"
:rule-type="RuleType" :rule-type="RuleType"
/> />
<Detail v-if="actionType === 'detail'" :current-row="currentRow" />
<template #footer>
<ElButton v-if="actionType !== 'detail'" type="primary" :loading="saveLoading" @click="save">
{{ t('dialogDemo.save') }}
</ElButton>
<ElButton @click="dialogVisible = false">{{ t('dialogDemo.close') }}</ElButton>
</template>
</Dialog> </Dialog>
</template> </template>

@ -1,91 +0,0 @@
<script setup lang="tsx">
import { PropType, ref } from 'vue'
import { TableData } from '@/api/dataset/RepSetRule/types'
import { Descriptions, DescriptionsSchema } from '@/components/Descriptions'
const detailSchema = ref<DescriptionsSchema[]>([
{
field: 'ruleName',
label: '规则名称'
},
{
field: 'ruleClass',
label: '规则分类'
},
{
field: 'startDate',
label: '启用日期'
},
{
field: 'ruleProperty',
label: '规则属性'
},
{
field: 'ruleCycle',
label: '规则周期'
},
{
field: 'ruleStatus',
label: '是否有效'
},
{
field: 'description',
label: '规则描述'
},
{
field: 'createDate',
label: '创建日期'
},
{
field: 'createAccount',
label: '创建账户'
},
{
field: 'createOrgan',
label: '创建机构'
},
{
field: 'ruleJson',
label: '规则json'
},
{
field: 'ruleSql',
label: '规则sql'
},
{
field: 'organCode',
label: '机构编码'
},
{
field: 'failDate',
label: '失效日期'
},
{
field: 'indexCode',
label: '规则加工指标集编号'
},
{
field: 'machFormulas',
label: '规则加载所有公式'
},
{
field: 'itemId',
label: '指标代码'
},
{
field: 'itemName',
label: '指标名称'
}
])
defineProps({
currentRow: {
type: Object as PropType<TableData>,
default: () => {}
}
})
</script>
<template>
<Descriptions :schema="detailSchema" :data="currentRow || {}" />
</template>
Loading…
Cancel
Save