You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

322 lines
7.8 KiB

<script setup lang="tsx">
import { onMounted, reactive, ref, unref } from 'vue'
import {
getIndexCategoryListApi,
delIndexCategoryListApi,
delIndexCategoryApi,
queryIndexCategoryApi,
getIndexCategoryTreeApi
} from '@/api/dataset/IndexCategory'
import { TableData } from '@/api/role/types'
import { useTable } from '@/hooks/web/useTable'
import { useI18n } from '@/hooks/web/useI18n'
import { Table, TableColumn } from '@/components/Table'
import {
ElButton,
ElLink,
ElLoading,
ElPopconfirm,
ElMessage,
ElRow,
ElCol,
ElTree
} from 'element-plus'
import { Search } from '@/components/Search'
import { FormSchema } from '@/components/Form'
import { ContentWrap } from '@/components/ContentWrap'
import Write from './components/Write.vue'
import Detail from './components/Detail.vue'
import { Dialog } from '@/components/Dialog'
import {useRouter} from "vue-router"
const router = useRouter();
import { getDateByPrevMonth } from '@/utils/dateUtil';
import { useAppStoreWithOut } from '@/store/modules/app'
import { useStorage } from '@/hooks/web/useStorage'
import { getIndexType } from '@/api/dataset/RepIndexSet'
import { transfDictList } from '@/utils';
const date = getDateByPrevMonth();
const appStore = useAppStoreWithOut()
const { getStorage } = useStorage()
const userInfo = getStorage(appStore.getUserInfo)
let frequency_param_LIST = ref([]);
let indexType_param_LIST = ref([]);
//获取字典项
const getDictInfoList = async ()=>{
const res = await getIndexType({ paramName: 'frequency_param', systemCode: 'ordb' });
frequency_param_LIST.value = transfDictList(res.body.result);
const indexType = await getIndexType({ paramName: 'indexType_param', systemCode: 'ordb' });
indexType_param_LIST.value = transfDictList(indexType.body.result);
}
getDictInfoList();
defineOptions({
name: 'IndexSearchServiceMs',
});
const { t } = useI18n()
const ids = ref<string[]>([])
const { tableRegister, tableState, tableMethods } = useTable({
fetchDataApi: async () => {
const { currentPage, pageSize } = tableState
const res = await getIndexCategoryListApi({
pageNum: unref(currentPage),
pageSize: unref(pageSize),
createUser: userInfo.session_loginName,
...unref(searchParams)
})
return {
list: res.body.list,
total: res.body.total
}
},
fetchDelApi: async () => {
const res = await delIndexCategoryListApi(unref(ids))
return !!res
}
})
const { loading, dataList, total, currentPage, pageSize } = tableState
const { getList, refresh } = tableMethods
const tableColumns = reactive<TableColumn[]>([
{
field: 'selection',
type: 'selection'
},
{
field: 'indexsetCode',
label: '指标集编码',
width:100
},
{
field: 'indexsetName',
label: '指标集名称',
width:100
},
{
field: 'code',
label: '指标代码'
},
{
field: 'itemName',
label: '指标名称',
width:100
},
{
field: 'businessDefinition',
label: '业务定义'
},
{
field: 'indexType',
label: '指标类型',
slots:{
default:(data)=>{
return <span>{data.row.indexType?indexType_param_LIST.value[data.row.indexType - 1]?.label:''}</span>
}
}
},
{
field: 'frequency',
label: '频度',
slots:{
default:(data)=>{
return <span>{data.row.frequency?frequency_param_LIST.value[data.row.frequency]?.label:''}</span>
}
}
},
{
field: 'beginDate',
label: '生效日期',
width:180,
headerAlign:'center',
slots:{
default:(data:any)=>{
return <span>{data.row.beginDate}{data.row.endDate}</span>
}
}
},
{
field: 'action',
label: t('tableDemo.action'),
width:160,
slots: {
default: (data: any) => {
return (
<>
<ElLink type="primary" underline={false} onClick={() => lookRule(data.row)}>
{'查询'}
</ElLink>
</>
)
}
}
}
])
const searchSchema = reactive<FormSchema[]>([
{
field: 'dicname',
label: '指标名称',
component: 'Input'
}
])
const searchParams = ref({})
const setSearchParams = (data: any) => {
searchParams.value = data
getList()
}
const dialogVisible = ref(false)
const dialogTitle = ref('')
const currentRow = ref()
const actionType = ref('')
const writeRef = ref<ComponentRef<typeof Write>>()
/**单行查询**/
const action = async (row: any, type: string) => {
let detailLoading = ElLoading.service({
background: 'rgba(0, 0, 0, 0.7)'
})
const res = await queryIndexCategoryApi(row.dicid)
.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 lookRule = (data)=>{
router.push({
name:'IndexSearchServiceMs',
query:{
indexsetCode:data.indexsetCode,
frequency:data.frequency,
reportDate: date,
organId: userInfo.session_organCode
}
})
}
/** 单行删除 */
const delData = async (row: TableData) => {
const res = await delIndexCategoryApi(row.dicid)
if (res) {
const { code, errMsg } = res.head
if (code === '0') {
ElMessage.success('删除成功!')
getList()
} else {
ElMessage.error(errMsg || '删除失败!')
}
}
}
const disabled = ref(true)
const onSelectionChange = (selection: TableData[]) => {
disabled.value = selection.length === 0
}
const treeData = ref<any>([])
onMounted(() => {
getIndexCategoryTreeApi().then((res) => (treeData.value = res))
})
const defaultProps = { children: 'childs', label: 'nodeName' }
const queryOntInfo = (node,data)=>{
console.log(node,data)
setSearchParams({dicid:data.id});
/*queryIndexCategoryApi(data.props.dicid).then(res=>{
console.log(res,"查询的信息");
dataList = [];
if(res.body.result){
dataList.push(res.body.result);
}
})*/
}
</script>
<template>
<ContentWrap>
<Search :schema="searchSchema" @reset="setSearchParams" @search="setSearchParams" />
<ElRow>
<ElCol :span="6" style="padding: 10px"
><ElTree :data="treeData" :props="defaultProps" nodeKey="id">
<template #default="{ node, data }">
<span class="r-tree-title">
<span class="r-plain-tree-title" @click="queryOntInfo(node,data)">{{ node.label }}</span>
</span>
</template>
</ElTree>
</ElCol>
<ElCol :span="18">
<Table
:columns="tableColumns"
v-model:pageSize="pageSize"
v-model:currentPage="currentPage"
default-expand-all
node-key="id"
:data="dataList"
:loading="loading"
:pagination="{
total
}"
@selection-change="onSelectionChange"
@register="tableRegister"
@refresh="refresh"
/>
</ElCol>
</ElRow>
</ContentWrap>
<Dialog v-model="dialogVisible" :title="dialogTitle">
<Write
v-if="actionType !== 'detail'"
ref="writeRef"
:current-row="currentRow"
:action-type="actionType"
/>
<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>
<style lang="less" scoped>
.el-tree-node {
.el-link {
opacity: 0;
margin-left: 6px;
}
}
.el-tree-node__content:hover .el-link {
opacity: 1;
}
</style>