修改数据钻取的按机构钻取联调完成

main
于阔 9 months ago
parent 72223e11ad
commit 5c6f699d55

@ -80,3 +80,12 @@ export const getIndexSetTreeApi = async () => {
return [];
};
//按机构钻取指标/RepIndexSet/spi/dataset/RepIndexSet/RepIndexSetDrilling
export const RepIndexSetDrilling = (data: any) => {
return request.postJson({ url: '/RepIndexSet/spi/dataset/RepIndexSet/RepIndexSetDrilling', data });
};
//获取父级机构信息/RepIndexSet/spi/dataset/RepIndexSet/RepIndexSetDrillingQuery
export const RepIndexSetDrillingQuery = (data: any) => {
return request.postJson({ url: '/RepIndexSet/spi/dataset/RepIndexSet/RepIndexSetDrillingQuery', data });
};

@ -18,5 +18,350 @@ export function formatToDate(date?: dayjs.ConfigType, format = DATE_FORMAT): str
export function getDateByPrevMonth(date?: dayjs.ConfigType, format = DATE_FORMAT): string {
return dayjs(date).subtract(1, 'month').endOf('month').format(format)
}
export const dateUtil = dayjs
//获取reportDate
export function getReportDateOfValue(row,field){
let resultDate = row.paramDate;
//上期值
if(field == 'prevPeriodValue'){
switch (row.frequency) {
//日报 : 上期取前一天数据
case '0':
var dateString = resultDate.substring(0,4) + "-" + resultDate.substring(4,6) + "-" +resultDate.substring(6,resultDate.length);
var dateTime = new Date(Date.parse(dateString.replace(/-/g, "/")));
dateTime.setDate(dateTime.getDate() - 1);
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1 < 10 ? "0" + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1;
var day = dateTime.getDate() < 10 ? "0" + dateTime.getDate() : dateTime.getDate();
resultDate = year + "" + month + "" + day;
break;
//旬报:上期取上月同一期
case '1':
var stringYear = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
var partOfMonth = resultDate.substring(6,resultDate.length);
if(parseInt(month) == 1){
var year = parseInt(stringYear) - 1;
resultDate = year + "12" + partOfMonth;
}else{
var stringMonth = parseInt(month) - 1;
resultDate = stringYear + '' + stringMonth + '' + partOfMonth;
}
break;
//月报:上期取上个月
case '2':
var stringYear = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
var stringMonth = parseInt(month) - 1;
if(stringMonth == 0){
stringYear = parseInt(stringYear) - 1;
stringMonth = "12";
}
if (stringMonth < 10) {
stringMonth = '0' + stringMonth;
}
resultDate = stringYear + '' + stringMonth + "00";
break;
//季报:上期取上季度
case '3':
var year = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
if(parseInt(month) <= 3){
var stringYear = parseInt(year)-1;
resultDate = stringYear + "1200";
}else if(parseInt(month) > 3 && parseInt(month) <= 6){
resultDate = year + "0300";
}else if(parseInt(month) > 6 && parseInt(month) <= 9){
resultDate = year + "0600";
}else if(parseInt(month) > 9 && parseInt(month) <= 12){
resultDate = year + "0900";
}
break;
//半年报:上期取
case '4':
var year = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
if(parseInt(month) <= 6 ){
var stringYear = parseInt(year)-1;
resultDate = stringYear + "1200";
}else if(parseInt(month) > 6 && parseInt(month) <= 12){
resultDate = year + "0600";
}
break;
//年报:上期取上一年
case '5':
var year = resultDate.substring(0,4);
var stringYear = parseInt(year)-1;
resultDate = stringYear + '' + resultDate.substring(4,resultDate.length);
break;
default:
resultDate = row.paramDate;
break;
}
}
//年初值
if(field == 'yearAtFirstValue'){
switch (row.frequency) {
case '0':
var stringYear = resultDate.substring(0,4);
var year = parseInt(stringYear) - 1;
resultDate = year + "1200";
break;
case '1':
var stringYear = resultDate.substring(0,4);
var year = parseInt(stringYear) - 1;
resultDate = year + "1200";
break;
case '2':
var stringYear = resultDate.substring(0,4);
var year = parseInt(stringYear) - 1;
resultDate = year + "1200";
break;
case '3':
var stringYear = resultDate.substring(0,4);
var year = parseInt(stringYear) - 1;
resultDate = year + "1200";
break;
case '4':
var stringYear = resultDate.substring(0,4);
var year = parseInt(stringYear) - 1;
resultDate = year + "1200";
break;
case '5':
var stringYear = resultDate.substring(0,4);
var year = parseInt(stringYear) - 1;
resultDate = year + "1200";
break;
default:
resultDate = row.paramDate;
break;
}
}
//上年同期
if(field == 'prevYearValue'){
switch (row.frequency) {
//日报:上年同期取上年同一天
case '0':
// var year = resultDate.substring(0,4);
// var month = resultDate.substring(4,6);
// var day = resultDate.substring(6,resultDate.length);
// var stringYear = parseInt(year) - 1;
// resultDate = stringYear + month + day;
var dateString = resultDate.substring(0,4) + "-" + resultDate.substring(4,6) + "-" +resultDate.substring(6,resultDate.length);
var dateTime = new Date(Date.parse(dateString.replace(/-/g, "/")));
dateTime.setFullYear(dateTime.getFullYear() - 1);
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1 < 10 ? "0" + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1;
var day = dateTime.getDate() < 10 ? "0" + dateTime.getDate() : dateTime.getDate();
resultDate = year + "" + month + "" + day;
break;
//旬报;上年同期取上年同月
case '1':
var stringYear = resultDate.substring(0,4);
var year = parseInt(stringYear) - 1;
resultDate = year + '' + resultDate.substring(4,resultDate.length);
break;
//月报:上年同期取上年同月
case '2':
var year = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
var stringYear = parseInt(year) - 1;
resultDate = stringYear + '' + month + "00";
break;
//季报:上年同期取上年同季度
case '3':
var year = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
var stringYear = parseInt(year) - 1;
resultDate = stringYear + '' + month + "00";
break;
//半年报:上年同期取
case '4':
var year = resultDate.substring(0,4);
// var month = resultDate.substring(4,6);
var stringYear = parseInt(year) - 1;
// resultDate = stringYear + month + "00";
resultDate = stringYear + '' + resultDate.substring(4,resultDate.length);
break;
//年报:
case '5':
var year = resultDate.substring(0,4);
// var month = resultDate.substring(4,6);
var stringYear = parseInt(year)-1;
// resultDate = stringYear + month + "00";
resultDate = stringYear + '' + resultDate.substring(4,resultDate.length);
break;
default:
resultDate = row.paramDate;
break;
}
}
//上日值
if(field == 'cprevDayValue'){
switch (row.frequency) {
//日报:
case '0':
var dateString = resultDate.substring(0,4) + "-" + resultDate.substring(4,6) + "-" +resultDate.substring(6,resultDate.length);
var dateTime = new Date(Date.parse(dateString.replace(/-/g, "/")));
dateTime.setDate(dateTime.getDate() - 1);
var year = dateTime.getFullYear();
var month = dateTime.getMonth() + 1 < 10 ? "0" + (dateTime.getMonth() + 1) : dateTime.getMonth() + 1;
var day = dateTime.getDate() < 10 ? "0" + dateTime.getDate() : dateTime.getDate();
resultDate = year + "" + month + "" + day;
break;
case '1':
resultDate = row.paramDate;
break;
case '2':
resultDate = row.paramDate;
break;
case '3':
resultDate = row.paramDate;
break;
case '4':
resultDate = row.paramDate;
break;
case '5':
resultDate = row.paramDate;
break;
default:
resultDate = row.paramDate;
break;
}
}
//上月值
if(field == 'cprevMonthValue'){
switch (row.frequency) {
//日报:
case '0':
//上月值取上月月末最后一日数据(保持跟后台一致)
var dateString = resultDate.substring(0,4) + "-" + resultDate.substring(4,6) + "-" +resultDate.substring(6,resultDate.length);
var dateTime = new Date(Date.parse(dateString.replace(/-/g, "/")));
var year = dateTime.getFullYear();
var month = dateTime.getMonth();
if (month == 0) {
month = 12;
year = year - 1;
}
if (month < 10) {
month = '0' + month;
}
var myDate = new Date(year, month, 0);
resultDate = year + "" + month + "" + myDate.getDate();
//上月值取上月同一天
// var dateString = resultDate.substring(0,4) + "-" + resultDate.substring(4,6) + "-" +resultDate.substring(6,resultDate.length);
// var dateTime = new Date(Date.parse(dateString.replace(/-/g, "/")));
// var year = dateTime.getFullYear();
// var month = dateTime.getMonth() + 1;
// var day = dateTime.getDate();
// if(parseInt(month) < 10){
// month = "0" + month;
// }
// if(parseInt(day) < 10){
// day = "0" + day;
// }
// resultDate = year + month + day;
// var preMonth = parseInt(month) - 1;
// preMonth = preMonth < 10 ? "0" + preMonth : preMonth;
// var preMonthDays = new Date(year, parseInt(month) - 1, 0).getDate();
// if(preMonthDays < parseInt(day)){
// resultDate = year + preMonth + preMonthDays;
// }
// if(parseInt(month) == 1){
// resultDate = parseInt(year) + "12" + day;
// }
break;
//旬报
case '1':
var stringYear = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
var partOfMonth = resultDate.substring(6,resultDate.length);
if(parseInt(month) == 1){
var year = parseInt(stringYear) - 1;
resultDate = year + "12" + partOfMonth;
}else{
var stringMonth = parseInt(month) - 1;
resultDate = stringYear + '' + stringMonth + '' + partOfMonth;
}
break;
//月报
case '2':
var stringYear = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
var stringMonth = parseInt(month) - 1;
if(stringMonth == 0){
stringYear = parseInt(stringYear) - 1;
stringMonth = "12";
}
if (stringMonth < 10) {
stringMonth = '0' + stringMonth;
}
resultDate = stringYear + '' + stringMonth + "00";
break;
case '3':
resultDate = row.paramDate;
break;
case '4':
resultDate = row.paramDate;
break;
case '5':
resultDate = row.paramDate;
break;
default:
resultDate = row.paramDate;
break;
}
}
//上季值
if(field == 'cprevQuarterValue'){
switch (row.frequency) {
//日报:取上季度末最后一天值
case '0':
var stringYear = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
if((parseInt(month)) <= 3){
var year = parseInt(stringYear) - 1;
resultDate = year + "12"+"31";
}else if((parseInt(month)) > 3 && (parseInt(month)) <= 6){
resultDate = stringYear + "03"+"31";
}else if((parseInt(month)) > 6 && (parseInt(month)) <= 9){
resultDate = stringYear + "06"+"30";
}else if((parseInt(month)) > 9 && (parseInt(month)) <= 12){
resultDate = stringYear + "09"+"30";
}
break;
case '1':
resultDate = row.paramDate;
break;
case '2':
resultDate = row.paramDate;
break;
case '3':
var stringYear = resultDate.substring(0,4);
var month = resultDate.substring(4,6);
if((parseInt(month)) <= 3){
var year = parseInt(stringYear) - 1;
resultDate = year + "12"+"00";
}else if((parseInt(month)) > 3 && (parseInt(month)) <= 6){
resultDate = stringYear + "03"+"00";
}else if((parseInt(month)) > 6 && (parseInt(month)) <= 9){
resultDate = stringYear + "06"+"00";
}else if((parseInt(month)) > 9 && (parseInt(month)) <= 12){
resultDate = stringYear + "09"+"00";
}
break;
case '4':
resultDate = row.paramDate;
break;
case '5':
resultDate = row.paramDate;
break;
default:
resultDate = row.paramDate;
break;
}
}
return resultDate;
}

@ -1,7 +1,8 @@
<script setup lang="tsx">
import { reactive, ref, unref } from 'vue'
import {
getRepIndexSearchListApi
getRepIndexSearchListApi,
queryRepIndexSetApi
} from '@/api/dataset/RepIndexSet'
import { TableData } from '@/api/reporting/RepDataProblem/RepDataProblem/types'
import { useTable } from '@/hooks/web/useTable'
@ -11,10 +12,9 @@ import { ElButton, ElLink, ElLoading, ElPopconfirm, ElMessage,ElDropdown,ElDropd
import { Search } from '@/components/Search'
import { FormSchema } from '@/components/Form'
import { ContentWrap } from '@/components/ContentWrap'
import Write from './components/Write.vue'
import DrillingOrAnalysis from './components/DrillingOrAnalysis.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'
@ -34,8 +34,8 @@ let frequency_param_LIST = ref([]);
//
const getDictInfoList = async ()=>{
const res = await getIndexType({ paramName: 'frequency_param', systemCode: 'ordb' });
frequency_param_LIST.value = transfDictList(res.body.result);
const res = await getIndexType({ paramName: 'frequency_param', systemCode: 'ordb' });
frequency_param_LIST.value = transfDictList(res.body.result);
}
getDictInfoList();
@ -135,7 +135,7 @@ const tableColumns = reactive<TableColumn[]>([
},
dropdown:()=>{
return <ElDropdownMenu>
<ElDropdownItem>
<ElDropdownItem onClick={()=>action(data.row,'DrillingByOrgan','按机构钻取','indexValue')}>
<div>按机构钻取</div>
</ElDropdownItem>
<ElDropdownItem>
@ -162,7 +162,7 @@ const tableColumns = reactive<TableColumn[]>([
},
dropdown:()=>{
return <ElDropdownMenu>
<ElDropdownItem>
<ElDropdownItem onClick={()=>action(data.row,'DrillingByOrgan','按机构钻取','prevPeriodValue')}>
<div>按机构钻取</div>
</ElDropdownItem>
<ElDropdownItem>
@ -243,82 +243,22 @@ const dialogTitle = ref('')
const currentRow = ref()
const actionType = ref('')
const writeRef = ref<ComponentRef<typeof Write>>()
/**单行查询**/
const action = async (row: TableData, type: string) => {
let detailLoading = ElLoading.service({
background: 'rgba(0, 0, 0, 0.7)'
})
const res = await queryRepDataProblemApi(row.pId)
.catch(() => {})
.finally(() => {
detailLoading.close()
})
detailLoading.close()
if (res) {
const data = res.body.result
dialogTitle.value = t(type === 'edit' ? 'tableDemo.edit' : 'tableDemo.detail')
actionType.value = type
currentRow.value = data
dialogVisible.value = true
}
}
const AddAction = () => {
dialogTitle.value = t('tableDemo.add')
currentRow.value = undefined
dialogVisible.value = true
actionType.value = 'add'
}
const saveLoading = ref(false)
/** 保存 **/
const save = async () => {
const write = unref(writeRef)
const formData = await write?.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)
/** 批量删除 **/
const delDataBatch = async () => {
const elTableExpose = await getElTableExpose()
ids.value = elTableExpose?.getSelectionRows().map((v: TableData) => { v.pId }) || []
delLoading.value = true
await delList(unref(ids).length).finally(() => {
delLoading.value = false
})
}
/** 单行删除 */
const delData = async (row: TableData) => {
const res = await delRepDataProblemApi(row.pId)
if (res) {
const { code, errMsg } = res.head
if (code === '0') {
ElMessage.success('删除成功!')
getList()
} else {
ElMessage.error(errMsg || '删除失败!')
}
}
const DrillingType = ref('');//
/**
row:当前行的数据信息
type:当前的操作类型
dialogTitle:弹框的标题
column:当前操作的列是本期值还是哪一期的值
**/
const action = async (row: TableData, type: string,title: string,column: string) => {
dialogTitle.value = title;//
actionType.value = column;//
currentRow.value = row;//
DrillingType.value = type;//
dialogVisible.value = true;//
}
const disabled = ref(true)
const disabled = ref(true);
const onSelectionChange = (selection: TableData[]) => {
disabled.value = selection.length === 0
@ -352,19 +292,12 @@ const onContextMenu = (row: any, column: any, cell: HTMLTableCellElement, event:
/>
</ContentWrap>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<Write
v-if="actionType !== 'detail'"
ref="writeRef"
<Dialog v-model="dialogVisible" :title="dialogTitle" style="min-width:800px;">
<DrillingOrAnalysis
ref="DrillingOrAnalysisRef"
:current-row="currentRow"
:action-type="actionType"
:drillingType="DrillingType"
/>
<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>
</template>

@ -1,30 +1,56 @@
<!-- 数据分析 -->
<template>
<Table
align="center"
headerAlign="center"
:columns="tableColumns"
:data="dataList"
:loading="loading"
row-key="randomCode"
lazy
style="max-height:300px;"
:showAction="false"
:load="loadJunior"
:tree-props="{ children: 'children', hasChildren: 'hasChildren'}"
/>
</template>
<script lang="tsx" setup>
import {
getRepIndexSearchListApi
RepIndexSetDrillingQuery,
RepIndexSetDrilling
} 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 {reactive, ref, unref,PropType} from 'vue';
import { randomCode } from '@/utils'
import {ElDropdown,ElDropdownMenu,ElDropdownItem,ElMessage} from 'element-plus';
const { tableRegister, tableState, tableMethods } = useTable({
const props = defineProps({
IndexData: {//
type: Object as PropType<any>,
default: () => null
},
actionType:{//
type: String,
default:''
}
})
console.log(props.IndexData);
const IndexData = ref(props.IndexData);
const { tableState, tableMethods } = useTable({
fetchDataApi: async () => {
const res = await getRepIndexSearchListApi({})
IndexData.value.organCode = IndexData.value.organId;
const res = await RepIndexSetDrillingQuery(IndexData.value);
if(res.head.code == '0'){
res.body.List = res.body.list.map((item:any)=>{
item.randomCode = randomCode(32);
item.hasChildren = true;
return item
})
}
return {
list: res.body.list,
total: res.body.total
@ -38,13 +64,15 @@ const tableColumns = reactive<TableColumn[]>([
{
field: 'organName',
label: '机构名称',
headerAlign:"left",
align:"left"
},
{
field: 'tCategory',
field: 'value',
label: '公式值',
slots:{
default:(data:any)=>{
return <span class="cursor-pointer" style="color:#d9ecff;">{data.row.tCategory}</span>
// slots:{
// default:(data:any)=>{
// return <span class="cursor-pointer" style="color:#d9ecff;">{data.row.value}</span>
// return <ElDropdown class="{prefixCls} custom-hover" style="vertical-align: middle;padding:0;" trigger="contextmenu" placement="right">
// {{
// default:()=>{
@ -64,8 +92,8 @@ const tableColumns = reactive<TableColumn[]>([
// }
// }}
// </ElDropdown>
}
}
// }
// }
}
])
/** 查询下级数据加载 */
@ -74,16 +102,22 @@ const loadJunior = async (
__: any,
resolve: (date: TableData[]) => void
) => {
const res = false;
// const formData = {
// id:row.id
// };
// const res = await getSubTaskListApi(formData);//hasChildrentrue
const params = reactive({
...row,
formula:IndexData.value.formula,
treeId:'1',
systemCode:'',//
});//
const res = await RepIndexSetDrilling(params);//hasChildrentrue
if (res) {
const data = res?.body?.list;
if(data.length == 0){
ElMessage.success("该任务下没有执行的子任务");
ElMessage.success("该机构下无下级机构");
}
data.forEach(item=>{
item.randomCode = randomCode(32)
item.hasChildren = true;
})
resolve(data)
}
}

@ -2,12 +2,12 @@
<template>
<ContentWrap>
<!-- 被钻取的指标信息 -->
<ElDivider>被钻取的指标信息</ElDivider>
<ElDivider contentPosition="left">被钻取的指标信息</ElDivider>
<Form @register="formRegister" :schema="formSchema" />
<!-- 钻取详情 -->
<ElDivider>钻取详情</ElDivider>
<ElDivider contentPosition="left">钻取详情</ElDivider>
<!-- 按机构钻取 -->
<DataDillingByOrgan :IndexData="IndexData" v-show="DrillingTYPE == 'DataDillingByOrgan'" />
<DataDillingByOrgan :IndexData="IndexData" :actionType="actionType" v-if="DrillingTYPE == 'DrillingByOrgan'" />
<!-- 趋势分析 -->
</ContentWrap>
@ -17,10 +17,33 @@ 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';//
import {getReportDateOfValue} from '@/utils/dateUtil';
import DataDillingByOrgan from './DataDillingByOrgan.vue';//
//
defineOptions({
name: 'DrillingOrAnalysis'
})
const props = defineProps({
currentRow: {
type: Object as PropType<any>,
default: () => null
},
drillingType: {
type: String,//DrillingByOrgan
default: ''
},
actionType:{
type: String,//
default: ''
}
})
const IndexData = reactive(props.currentRow);//
const DrillingTYPE = ref(props.drillingType);//
const actionType = ref(props.actionType);//
IndexData.date = getReportDateOfValue(IndexData,actionType.value);
const { formRegister, formMethods } = useForm()
const { setValues } = formMethods
const formSchema = reactive<FormSchema[]>([
@ -28,58 +51,83 @@ const formSchema = reactive<FormSchema[]>([
field: 'indexSetName',
label: '指标集',
component: 'Input',
readonly: true,
colProps: {
span: 12,
span: 6,
},
componentProps:{
disabled:true
}
},
{
field: 'indexItemCode',
label: '指标代码',
component: 'Input',
colProps: {
span: 6,
},
componentProps:{
disabled:true
}
},
{
field: 'indexName',
label: '指标名称',
component: 'Input',
colProps: {
span: 6,
},
componentProps:{
disabled:true
}
},
{
field: 'targetName',
label: '指标属性',
component: 'Input',
colProps: {
span: 6,
},
componentProps:{
disabled:true
}
},
{
field: 'organName',
label: '机构',
component: 'Input',
colProps: {
span: 6,
},
componentProps:{
disabled:true
}
},
{
field: 'paramDate',
label: '报告期',
field: 'date',
label: '报告期',
component: 'Input',
colProps: {
span: 6,
},
componentProps:{
disabled:true
}
},
{
field: 'cprevDayValue',
field: actionType.value?actionType.value:'indexValue',
label: '指标数值',//
component: 'Input',
colProps: {
span: 6,
},
componentProps:{
disabled:true
}
}
])
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);//
setValues(IndexData);//
</script>
<style scoped>
</style>
Loading…
Cancel
Save