指标管理

main
yangyuanshuai 10 months ago
parent 712a862b0e
commit c906860763

@ -15,12 +15,16 @@ import { ElButton, ElLink, ElLoading, ElPopconfirm, ElMessage } from 'element-pl
import { Search } from '@/components/Search'
import { FormSchema } from '@/components/Form'
import { ContentWrap } from '@/components/ContentWrap'
import RuleConfig from './components/Ruleconfig.vue'
import Write from './components/Write.vue'
import { Dialog } from '@/components/Dialog'
import { getWidth } from '@/utils';
import Detail from './components/Detail.vue'
import { method } from 'lodash-es'
const { t } = useI18n()
/**
* 指标定义
*/
const ids = ref<string[]>([])
@ -30,7 +34,7 @@ const { tableRegister, tableState, tableMethods } = useTable({
const res = await getRepDataProblemListApi({
pageIndex: unref(currentPage),
pageSize: unref(pageSize),
...unref(searchParams)
...unref(indexDefineSearchParams)
})
return {
list: res.body.list,
@ -45,8 +49,7 @@ const { tableRegister, tableState, tableMethods } = useTable({
const { loading, dataList, total, currentPage, pageSize } = tableState
const { getList, getElTableExpose, delList, refresh } = tableMethods
const tableColumns = reactive<TableColumn[]>([
const indexDefineTableColumns = reactive<TableColumn[]>([
{
field: 'selection',
type: 'selection',
@ -108,7 +111,7 @@ const tableColumns = reactive<TableColumn[]>([
}}
onConfirm={() => delData(data.row)}
></ElPopconfirm>
<ElLink type="primary" underline={false} onClick={() => action(data.row, 'detail')}>
<ElLink type="primary" underline={false} onClick={() => action(data.row, 'ruleconfig')}>
{'配置'}
</ElLink>
</>
@ -118,7 +121,67 @@ const tableColumns = reactive<TableColumn[]>([
}
].map(item => ({ minWidth: item.label ? getWidth(item.label) : 120, ...item }) as TableColumn))
const searchSchema = reactive<FormSchema[]>([
/**
* 指标属性
*/
const indexPropertiesTableColumns = reactive<TableColumn[]>([
{
field: 'selection',
type: 'selection',
fixed: true
},
{
field: 'dataDate',
label: '指标属性编号'
},
{
field: 'createTime',
label: '指标属性名称'
},
{
field: 'tCategory',
label: '开始时间'
},
{
field: 'tCategory',
label: '结束时间'
},
{
field: 'action',
label: t('tableDemo.action'),
width: 160,
fixed: 'right',
slots: {
default: (data: any) => {
return (
<>
<ElLink type="primary" underline={false} onClick={() => action(data.row, 'edit')}>
{t('tableDemo.edit')}
</ElLink>
<ElPopconfirm
title={t('common.delTableMsg')}
width={200}
v-slots={{
reference: () => {
return (
<>
<ElLink type="primary" underline={false}>
{t('tableDemo.del')}
</ElLink>
</>
)
}
}}
onConfirm={() => delData(data.row)}
></ElPopconfirm>
</>
)
}
}
}
].map(item => ({ minWidth: item.label ? getWidth(item.label) : 120, ...item }) as TableColumn))
const indexDefineSearchSchema = reactive<FormSchema[]>([
{
field: 'createTime',
label: '指标代码',
@ -146,9 +209,31 @@ const searchSchema = reactive<FormSchema[]>([
}
])
const searchParams = ref({})
const setSearchParams = (data: any) => {
searchParams.value = data
const indexPropertiesSearchSchema = reactive<FormSchema[]>([
{
field: 'createTime',
label: '编号',
componentProps: {},
component: 'Input'
},
{
field: 'tName',
label: '名称',
componentProps: {},
component: 'Input'
}
])
const indexDefineSearchParams = ref({})
const indexDefineSetSearchParams = (data: any) => {
indexDefineSearchParams.value = data
getList()
}
const indexPropertieSearchParams = ref({})
const indexPropertieSetSearchParams = (data: any) => {
indexPropertieSearchParams.value = data
getList()
}
@ -158,8 +243,8 @@ const dialogTitle = ref('')
const currentRow = ref()
const actionType = ref('')
const ruleConfigRef = ref<ComponentRef<typeof RuleConfig>>()
const writeRef = ref<ComponentRef<typeof Write>>()
/**单行查询**/
const action = async (row: TableData, type: string) => {
let detailLoading = ElLoading.service({
@ -173,7 +258,7 @@ const action = async (row: TableData, type: string) => {
detailLoading.close()
if (res) {
const data = res.body.result
dialogTitle.value = t(type === 'edit' ? 'tableDemo.edit' : 'tableDemo.detail')
dialogTitle.value = type === 'edit' ? '编辑' : '规则配置'
actionType.value = type
currentRow.value = data
dialogVisible.value = true
@ -207,6 +292,25 @@ const save = async () => {
}
}
/** 添加指标加工规则**/
const addRuleConfig = async () => {
const ruleConfig = unref(ruleConfigRef)
const formData = await ruleConfig?.submit()
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 delLoading = ref(false)
/** 批量删除 **/
@ -238,53 +342,95 @@ const disabled = ref(true)
const onSelectionChange = (selection: TableData[]) => {
disabled.value = selection.length === 0
}
const activeName = ref('indexDefination')
const handleClick=(tab: any, event: Event | undefined)=> {
console.log(tab,event);
}
</script>
<template>
<ContentWrap>
<Search :schema="searchSchema" @reset="setSearchParams" @search="setSearchParams" />
<Table
:columns="tableColumns"
v-model:pageSize="pageSize"
v-model:currentPage="currentPage"
default-expand-all
node-key="pId"
:data="dataList"
:loading="loading"
:pagination="{
total
}"
@selection-change="onSelectionChange"
@register="tableRegister"
@refresh="refresh"
>
<template #buttons>
<ElButton type="primary" @click="AddAction">{{ t('tableDemo.add') }}</ElButton>
<ElButton :loading="delLoading" type="primary" :disabled="disabled" @click="delDataBatch()">
{{ t('tableDemo.del') }}
</ElButton>
<ElButton type="primary" :disabled="disabled" @click="AddAction">{{'EXCEL'}}</ElButton>
<ElButton :loading="delLoading" type="primary" @click="delDataBatch()">
{{'导入excel'}}
</ElButton>
</template>
</Table>
</ContentWrap>
<ElTabs v-model="activeName" type="" @tab-click="handleClick">
<ElTabPane label="指标定义" name="indexDefination">
<ContentWrap>
<Search :schema="indexDefineSearchSchema" @reset="indexDefineSetSearchParams" @search="indexDefineSetSearchParams" />
<Table
:columns="indexDefineTableColumns"
v-model:pageSize="pageSize"
v-model:currentPage="currentPage"
default-expand-all
node-key="pId"
:data="dataList"
:loading="loading"
:pagination="{
total
}"
@selection-change="onSelectionChange"
@register="tableRegister"
@refresh="refresh"
>
<template #buttons>
<ElButton type="primary" @click="AddAction">{{ t('tableDemo.add') }}</ElButton>
<ElButton :loading="delLoading" type="primary" :disabled="disabled" @click="delDataBatch()">
{{ t('tableDemo.del') }}
</ElButton>
<ElButton type="primary" :disabled="disabled" @click="AddAction">{{ 'EXCEL' }}</ElButton>
<ElButton :loading="delLoading" type="primary" @click="delDataBatch()">
{{ '导入excel' }}
</ElButton>
</template>
</Table>
</ContentWrap>
</ElTabPane>
<ElTabPane label="指标属性" name="indexProperties">
<ContentWrap>
<Search :schema="indexPropertiesSearchSchema" @reset="indexPropertieSetSearchParams" @search="indexPropertieSetSearchParams" />
<Table
:columns="indexPropertiesTableColumns"
v-model:pageSize="pageSize"
v-model:currentPage="currentPage"
default-expand-all
node-key="pId"
:data="dataList"
:loading="loading"
:pagination="{
total
}"
@selection-change="onSelectionChange"
@register="tableRegister"
@refresh="refresh"
>
<template #buttons>
<ElButton type="primary" @click="AddAction">{{ t('tableDemo.add') }}</ElButton>
<ElButton :loading="delLoading" type="primary" :disabled="disabled" @click="delDataBatch()">
{{ t('tableDemo.del') }}
</ElButton>
<ElButton type="primary" :disabled="disabled" @click="AddAction">{{ 'EXCEL' }}</ElButton>
<ElButton :loading="delLoading" type="primary" @click="delDataBatch()">
{{ '导入excel' }}
</ElButton>
</template>
</Table>
</ContentWrap>
</ElTabPane>
</ElTabs>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<Write
v-if="actionType !== 'detail'"
v-if="actionType !== 'ruleconfig'"
ref="writeRef"
:current-row="currentRow"
:action-type="actionType"
/>
<Detail v-if="actionType === 'detail'" :current-row="currentRow" />
<RuleConfig v-if="actionType === 'ruleconfig'" />
<template #footer>
<ElButton v-if="actionType !== 'detail'" type="primary" :loading="saveLoading" @click="save">
<ElButton v-if="actionType == 'edit'" type="primary" :loading="saveLoading" @click="save">
{{ t('dialogDemo.save') }}
</ElButton>
<ElButton v-if="actionType == 'ruleconfig'" type="primary" :loading="saveLoading" @click="addRuleConfig">
{{ t('formDemo.add') }}
</ElButton>
<ElButton @click="dialogVisible = false">{{ t('dialogDemo.close') }}</ElButton>
</template>
</Dialog>

@ -0,0 +1,84 @@
<script setup lang="tsx">
import { Form, FormSchema } from '@/components/Form'
import { useForm } from '@/hooks/web/useForm'
import { PropType, reactive, watch } from 'vue'
import { useValidator } from '@/hooks/web/useValidator'
import { Value } from 'sass';
// import { getWorkFlowVisiableButton } from '@/api/csck/CsckFlow';
const { required } = useValidator()
const props = defineProps({
currentRow: {
type: Object as PropType<any>,
default: () => null
},
actionType: {
type: String,
default: 'submit'
}
})
const formSchema = reactive<FormSchema[]>([
{
field: 'ruleType',
label: '加工规则类型:',
component: 'Select',
componentProps:{
options: [
{
label: '指标规则',
value: '0'
},
{
label: 'SQL规则',
value: '1'
},
{
label: '存储过程规则',
value: '2'
}
]
},
value: '1'
}
])
const rules = reactive({
ruleType: [required()],
})
const { formRegister, formMethods } = useForm()
const { setValues, getFormData, getElFormExpose } = formMethods
const submit = async () => {
const elForm = await getElFormExpose()
const valid = await elForm?.validate().catch((err) => {
console.log(err)
})
if (valid) {
const formData = await getFormData()
return formData
}
}
watch(
() => props.currentRow,
(currentRow) => {
if (!currentRow) return
setValues(currentRow)
},
{
deep: true,
immediate: true
}
)
defineExpose({
submit
})
</script>
<template>
<Form :rules="rules" @register="formRegister" :schema="formSchema" />
</template>

@ -19,9 +19,15 @@ import Write from './components/Write.vue'
import { Dialog } from '@/components/Dialog'
import { getWidth } from '@/utils';
import Detail from './components/Detail.vue'
import { useValidator } from '@/hooks/web/useValidator'
import { getLoginOrganCodeByUserInfo } from '@/utils/auth'
import { getOrganTree } from '@/api/common'
const { t } = useI18n()
const { required } = useValidator();
//
const loginOrganCode = getLoginOrganCodeByUserInfo();
const ids = ref<string[]>([])
const { tableRegister, tableState, tableMethods } = useTable({
@ -54,82 +60,73 @@ const tableColumns = reactive<TableColumn[]>([
},
{
field: 'dataDate',
label: '数据日期'
label: '指标代码'
},
{
field: 'createTime',
label: '生成时间'
label: '机构'
},
{
field: 'tName',
label: '报告名称'
label: '日期'
},
{
field: 'tCategory',
label: '报告分类'
label: '本期值'
},
{
field: 'action',
label: t('tableDemo.action'),
width: 160,
fixed: 'right',
slots: {
default: (data: any) => {
return (
<>
<ElLink type="primary" underline={false} onClick={() => action(data.row, 'edit')}>
{t('tableDemo.edit')}
</ElLink>
<ElPopconfirm
title={t('common.delTableMsg')}
width={200}
v-slots={{
reference: () => {
return (
<>
<ElLink type="primary" underline={false}>
{t('tableDemo.del')}
</ElLink>
</>
)
}
}}
onConfirm={() => delData(data.row)}
></ElPopconfirm>
<ElLink type="primary" underline={false} onClick={() => action(data.row, 'detail')}>
{t('tableDemo.detail')}
</ElLink>
</>
)
}
}
field: 'tCategory',
label: '上期值'
}
].map(item => ({ minWidth: item.label ? getWidth(item.label) : 120, ...item }) as TableColumn))
const searchSchema = reactive<FormSchema[]>([
{
field: 'createTime',
label: '生成时间',
componentProps: {type: 'daterange'},
component: 'DatePicker'
field: 'orgCode',
label: '机构',
componentProps: {
checkStrictly: true,
nodeKey: 'id',
props: { children: 'childs', label: 'nodeName' },
filterable: true,
multiple: true,
collapseTags: true,
showCheckbox: true,
// style: { minWidth: '300px' },
style: 'width: 100%',
checkOnClickNode: true,
},
component: 'TreeSelect',
optionApi: async () => {
const res = await getOrganTree({
treeid: '1',
systemCode: 'portal',
loginOrganCode,
});
return res.body.result;
},
value: loginOrganCode,
formItemProps: {
rules: [required()],
},
},
{
field: 'tName',
label: '报告名称',
label: '日期',
componentProps: {},
component: 'Input'
component: 'Input',
formItemProps: {
rules: [required()],
},
},
{
field: 'tCategory',
label: '报告分类',
componentProps: {},
component: 'Select'
},
{
field: 'organCode',
label: '所属机构',
label: '指标代码',
componentProps: {},
component: 'Select'
component: 'Select',
formItemProps: {
rules: [required()],
},
}
])
@ -225,6 +222,10 @@ const disabled = ref(true)
const onSelectionChange = (selection: TableData[]) => {
disabled.value = selection.length === 0
}
const onContextMenu = (row: any, column: any, cell: HTMLTableCellElement, event: Event) => {
console.log(row,column,cell,event);
}
</script>
@ -246,6 +247,7 @@ const onSelectionChange = (selection: TableData[]) => {
@selection-change="onSelectionChange"
@register="tableRegister"
@refresh="refresh"
@cell-contextmenu="onContextMenu"
>
<template #buttons>
<ElButton type="primary" @click="AddAction">{{ t('tableDemo.add') }}</ElButton>

Loading…
Cancel
Save