parent
d9d8a9a9e1
commit
6742875503
@ -0,0 +1,314 @@
|
||||
<script setup lang="tsx">
|
||||
import { onMounted, reactive, ref, unref } from 'vue'
|
||||
import {
|
||||
getSysMenuListApi,
|
||||
saveSysMenuApi,
|
||||
delSysMenuListApi,
|
||||
delSysMenuApi,
|
||||
querySysMenuApi
|
||||
} from '@/api/system/SysMenu'
|
||||
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 { getMenuTreeApi } from '@/api/common'
|
||||
|
||||
defineOptions({
|
||||
name: 'SysMenu'
|
||||
})
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const ids = ref<string[]>([])
|
||||
|
||||
const { tableRegister, tableState, tableMethods } = useTable({
|
||||
fetchDataApi: async () => {
|
||||
const { currentPage, pageSize } = tableState
|
||||
const res = await getSysMenuListApi({
|
||||
pageNum: unref(currentPage),
|
||||
pageSize: unref(pageSize),
|
||||
...unref(searchParams)
|
||||
})
|
||||
return {
|
||||
list: res.body.list,
|
||||
total: res.body.total
|
||||
}
|
||||
},
|
||||
fetchDelApi: async () => {
|
||||
const res = await delSysMenuListApi(unref(ids))
|
||||
return !!res
|
||||
}
|
||||
})
|
||||
|
||||
const { loading, dataList, total, currentPage, pageSize } = tableState
|
||||
const { getList, refresh } = tableMethods
|
||||
|
||||
const tableColumns = reactive<TableColumn[]>([
|
||||
{
|
||||
field: 'selection',
|
||||
type: 'selection'
|
||||
},
|
||||
{
|
||||
field: 'name',
|
||||
label: '分类编号'
|
||||
},
|
||||
{
|
||||
field: 'parentId',
|
||||
label: '分类名称'
|
||||
},
|
||||
{
|
||||
field: 'systemCode',
|
||||
label: '分类值'
|
||||
},
|
||||
{
|
||||
field: 'sort',
|
||||
label: '上级分类'
|
||||
},
|
||||
{
|
||||
field: 'sort',
|
||||
label: '分类描述'
|
||||
},
|
||||
{
|
||||
field: 'sort',
|
||||
label: '分类状态'
|
||||
},
|
||||
{
|
||||
field: 'action',
|
||||
label: t('tableDemo.action'),
|
||||
width: 160,
|
||||
slots: {
|
||||
default: (data: any) => {
|
||||
return (
|
||||
<>
|
||||
<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')}>
|
||||
{'查询'}
|
||||
</ElLink>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
])
|
||||
|
||||
const searchSchema = reactive<FormSchema[]>([
|
||||
{
|
||||
field: 'name',
|
||||
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 querySysMenuApi(row.id)
|
||||
.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 = (e: MouseEvent, node?: TableData) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
dialogTitle.value = t('tableDemo.add')
|
||||
currentRow.value = node ? { parentId: node.id, type: '1' } : undefined
|
||||
dialogVisible.value = true
|
||||
actionType.value = ''
|
||||
}
|
||||
|
||||
const saveLoading = ref(false)
|
||||
|
||||
/** 保存 **/
|
||||
const save = async () => {
|
||||
const write = unref(writeRef)
|
||||
const formData = await write?.submit()
|
||||
if (formData) {
|
||||
saveLoading.value = true
|
||||
const res = await saveSysMenuApi(formData)
|
||||
.catch(() => {})
|
||||
.finally(() => {
|
||||
saveLoading.value = false
|
||||
})
|
||||
if (res) {
|
||||
dialogVisible.value = false
|
||||
currentPage.value = 1
|
||||
getList()
|
||||
getMenuTreeApi().then((res) => (treeData.value = res))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 单行删除 */
|
||||
const delData = async (row: TableData) => {
|
||||
const res = await delSysMenuApi(row.id)
|
||||
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(() => {
|
||||
getMenuTreeApi().then((res) => (treeData.value = res))
|
||||
})
|
||||
|
||||
const defaultProps = { children: 'childs', label: 'nodeName' }
|
||||
</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">{{ node.label }}</span>
|
||||
<span>
|
||||
<ElLink :underline="false" @click="(e) => AddAction(e, data)">
|
||||
<Icon icon="ep:circle-plus" :size="14" />
|
||||
</ElLink>
|
||||
<ElLink :underline="false" @click="() => action(data, 'edit')">
|
||||
<Icon icon="ep:edit" :size="14" />
|
||||
</ElLink>
|
||||
<ElPopconfirm
|
||||
@confirm="() => delData(data)"
|
||||
:title="t('common.delTableMsg')"
|
||||
:width="200"
|
||||
>
|
||||
<template #reference>
|
||||
<ElLink :underline="false">
|
||||
<Icon icon="ep:remove" :size="14" />
|
||||
</ElLink>
|
||||
</template>
|
||||
</ElPopconfirm>
|
||||
</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"
|
||||
>
|
||||
<template #buttons>
|
||||
<ElButton type="primary" @click="(e) => AddAction(e)">{{
|
||||
t('tableDemo.add')
|
||||
}}</ElButton>
|
||||
</template>
|
||||
</Table>
|
||||
</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>
|
@ -0,0 +1,43 @@
|
||||
<script setup lang="tsx">
|
||||
import { PropType, ref } from 'vue'
|
||||
import { TableData } from '@/api/reporting/RepDataProblem/RepDataProblem/types'
|
||||
import { Descriptions, DescriptionsSchema } from '@/components/Descriptions'
|
||||
|
||||
const detailSchema = ref<DescriptionsSchema[]>([
|
||||
{
|
||||
field: 'dataDate',
|
||||
label: '数据日期'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '生成时间'
|
||||
},
|
||||
{
|
||||
field: 'tId',
|
||||
label: '模板表id'
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
label: '报告名称'
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '报告分类'
|
||||
},
|
||||
{
|
||||
field: 'organCode',
|
||||
label: '所属机构'
|
||||
}
|
||||
])
|
||||
|
||||
defineProps({
|
||||
currentRow: {
|
||||
type: Object as PropType<TableData>,
|
||||
default: () => {}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Descriptions :schema="detailSchema" :data="currentRow || {}" />
|
||||
</template>
|
@ -0,0 +1,114 @@
|
||||
<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'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
const props = defineProps({
|
||||
currentRow: {
|
||||
type: Object as PropType<any>,
|
||||
default: () => null
|
||||
},
|
||||
actionType: {
|
||||
type: String,
|
||||
default: 'add'
|
||||
}
|
||||
})
|
||||
|
||||
const { formRegister, formMethods } = useForm()
|
||||
const { setValues, getFormData, getElFormExpose } = formMethods
|
||||
|
||||
const formSchema = reactive<FormSchema[]>([
|
||||
{
|
||||
field: 'pId',
|
||||
label: '主键',
|
||||
component: 'Input',
|
||||
hidden: true
|
||||
},{
|
||||
field: 'dataDate',
|
||||
label: '数据日期',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '生成时间',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
type: 'daterange'
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tId',
|
||||
label: '模板表id',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
label: '报告名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '报告分类',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'organCode',
|
||||
label: '所属机构',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
}
|
||||
])
|
||||
|
||||
const rules = reactive({
|
||||
|
||||
})
|
||||
|
||||
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>
|
||||
|
@ -0,0 +1,291 @@
|
||||
<script setup lang="tsx">
|
||||
import { reactive, ref, unref } from 'vue'
|
||||
import {
|
||||
getRepDataProblemListApi,
|
||||
saveRepDataProblemApi,
|
||||
delRepDataProblemListApi,
|
||||
delRepDataProblemApi,
|
||||
queryRepDataProblemApi,
|
||||
} from '@/api/reporting/RepDataProblem/RepDataProblem'
|
||||
import { TableData } from '@/api/reporting/RepDataProblem/RepDataProblem/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 } 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 { Dialog } from '@/components/Dialog'
|
||||
import { getWidth } from '@/utils';
|
||||
import Detail from './components/Detail.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const ids = ref<string[]>([])
|
||||
|
||||
const { tableRegister, tableState, tableMethods } = useTable({
|
||||
fetchDataApi: async () => {
|
||||
const { currentPage, pageSize } = tableState
|
||||
const res = await getRepDataProblemListApi({
|
||||
pageIndex: unref(currentPage),
|
||||
pageSize: unref(pageSize),
|
||||
...unref(searchParams)
|
||||
})
|
||||
return {
|
||||
list: res.body.list,
|
||||
total: res.body.total
|
||||
}
|
||||
},
|
||||
fetchDelApi: async () => {
|
||||
const res = await delRepDataProblemListApi(unref(ids));
|
||||
return !!res;
|
||||
},
|
||||
})
|
||||
|
||||
const { loading, dataList, total, currentPage, pageSize } = tableState
|
||||
const { getList, getElTableExpose, delList, refresh } = tableMethods
|
||||
|
||||
const tableColumns = reactive<TableColumn[]>([
|
||||
{
|
||||
field: 'selection',
|
||||
type: 'selection',
|
||||
fixed: true
|
||||
},
|
||||
{
|
||||
field: 'dataDate',
|
||||
label: '指标代码'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '指标名称'
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
label: '指标类型'
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '指标计算类型'
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
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>
|
||||
<ElLink type="primary" underline={false} onClick={() => action(data.row, 'detail')}>
|
||||
{'配置'}
|
||||
</ElLink>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
].map(item => ({ minWidth: item.label ? getWidth(item.label) : 120, ...item }) as TableColumn))
|
||||
|
||||
const searchSchema = reactive<FormSchema[]>([
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '指标代码',
|
||||
componentProps: {},
|
||||
component: 'Input'
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
label: '指标名称',
|
||||
componentProps: {},
|
||||
component: 'Input'
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '指标计算类型',
|
||||
componentProps: {},
|
||||
component: 'Select'
|
||||
},
|
||||
{
|
||||
field: 'organCode',
|
||||
label: '日期范围',
|
||||
componentProps: {type: 'daterange'},
|
||||
component: 'DatePicker'
|
||||
|
||||
}
|
||||
])
|
||||
|
||||
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: 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 disabled = ref(true)
|
||||
|
||||
const onSelectionChange = (selection: TableData[]) => {
|
||||
disabled.value = selection.length === 0
|
||||
}
|
||||
|
||||
</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>
|
||||
|
||||
<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>
|
@ -0,0 +1,43 @@
|
||||
<script setup lang="tsx">
|
||||
import { PropType, ref } from 'vue'
|
||||
import { TableData } from '@/api/reporting/RepDataProblem/RepDataProblem/types'
|
||||
import { Descriptions, DescriptionsSchema } from '@/components/Descriptions'
|
||||
|
||||
const detailSchema = ref<DescriptionsSchema[]>([
|
||||
{
|
||||
field: 'dataDate',
|
||||
label: '数据日期'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '生成时间'
|
||||
},
|
||||
{
|
||||
field: 'tId',
|
||||
label: '模板表id'
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
label: '报告名称'
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '报告分类'
|
||||
},
|
||||
{
|
||||
field: 'organCode',
|
||||
label: '所属机构'
|
||||
}
|
||||
])
|
||||
|
||||
defineProps({
|
||||
currentRow: {
|
||||
type: Object as PropType<TableData>,
|
||||
default: () => {}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Descriptions :schema="detailSchema" :data="currentRow || {}" />
|
||||
</template>
|
@ -0,0 +1,114 @@
|
||||
<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'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
const props = defineProps({
|
||||
currentRow: {
|
||||
type: Object as PropType<any>,
|
||||
default: () => null
|
||||
},
|
||||
actionType: {
|
||||
type: String,
|
||||
default: 'add'
|
||||
}
|
||||
})
|
||||
|
||||
const { formRegister, formMethods } = useForm()
|
||||
const { setValues, getFormData, getElFormExpose } = formMethods
|
||||
|
||||
const formSchema = reactive<FormSchema[]>([
|
||||
{
|
||||
field: 'pId',
|
||||
label: '主键',
|
||||
component: 'Input',
|
||||
hidden: true
|
||||
},{
|
||||
field: 'dataDate',
|
||||
label: '数据日期',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '生成时间',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
type: 'daterange'
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tId',
|
||||
label: '模板表id',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
label: '报告名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '报告分类',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'organCode',
|
||||
label: '所属机构',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
}
|
||||
])
|
||||
|
||||
const rules = reactive({
|
||||
|
||||
})
|
||||
|
||||
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>
|
||||
|
@ -0,0 +1,274 @@
|
||||
<script setup lang="tsx">
|
||||
import { reactive, ref, unref } from 'vue'
|
||||
import {
|
||||
getRepDataProblemListApi,
|
||||
saveRepDataProblemApi,
|
||||
delRepDataProblemListApi,
|
||||
delRepDataProblemApi,
|
||||
queryRepDataProblemApi,
|
||||
} from '@/api/reporting/RepDataProblem/RepDataProblem'
|
||||
import { TableData } from '@/api/reporting/RepDataProblem/RepDataProblem/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 } 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 { Dialog } from '@/components/Dialog'
|
||||
import { getWidth } from '@/utils';
|
||||
import Detail from './components/Detail.vue'
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const ids = ref<string[]>([])
|
||||
|
||||
const { tableRegister, tableState, tableMethods } = useTable({
|
||||
fetchDataApi: async () => {
|
||||
const { currentPage, pageSize } = tableState
|
||||
const res = await getRepDataProblemListApi({
|
||||
pageIndex: unref(currentPage),
|
||||
pageSize: unref(pageSize),
|
||||
...unref(searchParams)
|
||||
})
|
||||
return {
|
||||
list: res.body.list,
|
||||
total: res.body.total
|
||||
}
|
||||
},
|
||||
fetchDelApi: async () => {
|
||||
const res = await delRepDataProblemListApi(unref(ids));
|
||||
return !!res;
|
||||
},
|
||||
})
|
||||
|
||||
const { loading, dataList, total, currentPage, pageSize } = tableState
|
||||
const { getList, getElTableExpose, delList, refresh } = tableMethods
|
||||
|
||||
const tableColumns = reactive<TableColumn[]>([
|
||||
{
|
||||
field: 'selection',
|
||||
type: 'selection',
|
||||
fixed: true
|
||||
},
|
||||
{
|
||||
field: 'dataDate',
|
||||
label: '数据日期'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '生成时间'
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
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>
|
||||
<ElLink type="primary" underline={false} onClick={() => action(data.row, 'detail')}>
|
||||
{t('tableDemo.detail')}
|
||||
</ElLink>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
].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: 'tName',
|
||||
label: '报告名称',
|
||||
componentProps: {},
|
||||
component: 'Input'
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '报告分类',
|
||||
componentProps: {},
|
||||
component: 'Select'
|
||||
},
|
||||
{
|
||||
field: 'organCode',
|
||||
label: '所属机构',
|
||||
componentProps: {},
|
||||
component: 'Select'
|
||||
}
|
||||
])
|
||||
|
||||
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: 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 disabled = ref(true)
|
||||
|
||||
const onSelectionChange = (selection: TableData[]) => {
|
||||
disabled.value = selection.length === 0
|
||||
}
|
||||
|
||||
</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>
|
||||
</template>
|
||||
</Table>
|
||||
</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>
|
@ -0,0 +1,43 @@
|
||||
<script setup lang="tsx">
|
||||
import { PropType, ref } from 'vue'
|
||||
import { TableData } from '@/api/reporting/RepDataProblem/RepDataProblem/types'
|
||||
import { Descriptions, DescriptionsSchema } from '@/components/Descriptions'
|
||||
|
||||
const detailSchema = ref<DescriptionsSchema[]>([
|
||||
{
|
||||
field: 'dataDate',
|
||||
label: '数据日期'
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '生成时间'
|
||||
},
|
||||
{
|
||||
field: 'tId',
|
||||
label: '模板表id'
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
label: '报告名称'
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '报告分类'
|
||||
},
|
||||
{
|
||||
field: 'organCode',
|
||||
label: '所属机构'
|
||||
}
|
||||
])
|
||||
|
||||
defineProps({
|
||||
currentRow: {
|
||||
type: Object as PropType<TableData>,
|
||||
default: () => {}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Descriptions :schema="detailSchema" :data="currentRow || {}" />
|
||||
</template>
|
@ -0,0 +1,114 @@
|
||||
<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'
|
||||
|
||||
const { required } = useValidator()
|
||||
|
||||
const props = defineProps({
|
||||
currentRow: {
|
||||
type: Object as PropType<any>,
|
||||
default: () => null
|
||||
},
|
||||
actionType: {
|
||||
type: String,
|
||||
default: 'add'
|
||||
}
|
||||
})
|
||||
|
||||
const { formRegister, formMethods } = useForm()
|
||||
const { setValues, getFormData, getElFormExpose } = formMethods
|
||||
|
||||
const formSchema = reactive<FormSchema[]>([
|
||||
{
|
||||
field: 'pId',
|
||||
label: '主键',
|
||||
component: 'Input',
|
||||
hidden: true
|
||||
},{
|
||||
field: 'dataDate',
|
||||
label: '数据日期',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
label: '生成时间',
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
type: 'daterange'
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tId',
|
||||
label: '模板表id',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tName',
|
||||
label: '报告名称',
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'tCategory',
|
||||
label: '报告分类',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'organCode',
|
||||
label: '所属机构',
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
|
||||
},
|
||||
}
|
||||
])
|
||||
|
||||
const rules = reactive({
|
||||
|
||||
})
|
||||
|
||||
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>
|
||||
|
Loading…
Reference in new issue