提交 500396be authored 作者: kxjia's avatar kxjia

权限填报

上级 515fc6fb
<template> <template>
<div class="bank-report-table"> <div class="bank-report-table">
<!-- 加载遮罩层 -->
<div v-if="loading" class="loading-overlay">
<div class="loading-spinner">
<div class="spinner"></div>
<div class="loading-text">加载中...</div>
</div>
</div>
<vxe-toolbar> <vxe-toolbar>
<template #buttons> <template #buttons>
...@@ -9,7 +16,7 @@ ...@@ -9,7 +16,7 @@
</div> </div>
</template> </template>
<template #tools> <template #tools>
<vxe-button status="primary" icon="vxe-icon-save" @click="saveBatch()">保存</vxe-button> <vxe-button status="primary" icon="vxe-icon-save" @click="saveBatch()" :disabled="loading">保存</vxe-button>
</template> </template>
</vxe-toolbar> </vxe-toolbar>
<vxe-table <vxe-table
...@@ -22,6 +29,7 @@ ...@@ -22,6 +29,7 @@
height="auto" height="auto"
class="custom-table" class="custom-table"
:merge-cells="mergeCells" :merge-cells="mergeCells"
:loading="loading" <!-- 添加表格loading -->
> >
<vxe-column field="serialNumber" title="序号" width="50"></vxe-column> <vxe-column field="serialNumber" title="序号" width="50"></vxe-column>
<vxe-column field="project" title="项目" width="40"> <vxe-column field="project" title="项目" width="40">
...@@ -182,6 +190,9 @@ interface FormData { ...@@ -182,6 +190,9 @@ interface FormData {
rind:number rind:number
} }
// 初始化loading状态
const loading = ref(true)
onMounted(async ()=>{ onMounted(async ()=>{
if (route.query.taskId) { if (route.query.taskId) {
queryParam.value.taskId = Number(route.query.taskId); queryParam.value.taskId = Number(route.query.taskId);
...@@ -199,12 +210,20 @@ onMounted(async ()=>{ ...@@ -199,12 +210,20 @@ onMounted(async ()=>{
queryParam.value.tplCode = String(route.query.tplCode); queryParam.value.tplCode = String(route.query.tplCode);
} }
try {
await setTplItemMap() await setTplItemMap()
await setData(); await setData();
} catch (error) {
VxeUI.modal.message({
content: `初始化页面失败: ${error.message}`,
status: 'error'
});
} finally {
loading.value = false
}
}) })
const loading = ref(false)
const formData = reactive({}); const formData = reactive({});
const formValues = ref<FormData[]>([]) const formValues = ref<FormData[]>([])
...@@ -212,6 +231,8 @@ const formValues = ref<FormData[]>([]) ...@@ -212,6 +231,8 @@ const formValues = ref<FormData[]>([])
const saveBatch = async () => { const saveBatch = async () => {
try { try {
// 保存时也显示loading
const saveLoading = ref(true)
formValues.value = [] formValues.value = []
for (const strKey in formData) { for (const strKey in formData) {
...@@ -302,7 +323,7 @@ const setFormValues = async (pcode,code,valData,rind) => { ...@@ -302,7 +323,7 @@ const setFormValues = async (pcode,code,valData,rind) => {
} }
async function setData() { async function setData() {
try { try {
loading.value = true; loading.value = true; // 开始加载
const taskId = queryParam.value.taskId; const taskId = queryParam.value.taskId;
const tplid = queryParam.value.tplId; const tplid = queryParam.value.tplId;
Object.keys(formData).forEach(key => delete formData[key]); Object.keys(formData).forEach(key => delete formData[key]);
...@@ -397,11 +418,12 @@ async function setData() { ...@@ -397,11 +418,12 @@ async function setData() {
status: 'error' status: 'error'
}); });
} finally { } finally {
loading.value = false; loading.value = false; // 结束加载
} }
} }
async function setTplItemMap() { async function setTplItemMap() {
try { try {
loading.value = true; // 开始加载
const tplid = queryParam.value.tplId const tplid = queryParam.value.tplId
const tplItem = await allTplItems({ const tplItem = await allTplItems({
tplid: tplid, tplid: tplid,
...@@ -413,7 +435,7 @@ async function setTplItemMap() { ...@@ -413,7 +435,7 @@ async function setTplItemMap() {
} catch (error) { } catch (error) {
VxeUI.modal.message({ content: `加载数据失败: ${error.message}`, status: 'error' }) VxeUI.modal.message({ content: `加载数据失败: ${error.message}`, status: 'error' })
} finally { } finally {
loading.value = false; // 结束加载
} }
} }
const mergeCells = ref<VxeTablePropTypes.MergeCells>([ const mergeCells = ref<VxeTablePropTypes.MergeCells>([
...@@ -435,7 +457,48 @@ const mergeCells = ref<VxeTablePropTypes.MergeCells>([ ...@@ -435,7 +457,48 @@ const mergeCells = ref<VxeTablePropTypes.MergeCells>([
margin: 5px auto; margin: 5px auto;
width: 60%; width: 60%;
height:80vh; height:80vh;
position: relative; /* 为loading遮罩层定位 */
}
/* 加载遮罩层样式 */
.loading-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(255, 255, 255, 0.8);
display: flex;
align-items: center;
justify-content: center;
z-index: 9999;
}
.loading-spinner {
text-align: center;
} }
.spinner {
width: 40px;
height: 40px;
margin: 0 auto 10px;
border: 3px solid #f3f3f3;
border-top: 3px solid #1890ff;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loading-text {
font-size: 14px;
color: #1890ff;
font-weight: bold;
}
.custom-table { .custom-table {
width: 100%; width: 100%;
border: 1px solid #000; border: 1px solid #000;
......
...@@ -13,7 +13,9 @@ ...@@ -13,7 +13,9 @@
<template #title> <template #title>
{{ item.code }} - {{ item.nm }} {{ item.code }} - {{ item.nm }}
</template> </template>
<template #extra><a href="#" @click="gotoPage(item)">填报</a></template> <template #extra>
<a href="#" @click.prevent="gotoPage(item)">填报</a>
</template>
<span>年度:{{ item.vyear }} &nbsp;</span> <span>年度:{{ item.vyear }} &nbsp;</span>
<span>版本:{{ item.version }} &nbsp;</span> <span>版本:{{ item.version }} &nbsp;</span>
<span>节点数:{{ item.childNum }}</span><br> <span>节点数:{{ item.childNum }}</span><br>
...@@ -23,11 +25,12 @@ ...@@ -23,11 +25,12 @@
</a-row> </a-row>
</div> </div>
</a-card> </a-card>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, onMounted,toRaw } from 'vue'; import { ref, onMounted, computed,nextTick } from 'vue';
import { allTpls } from '../tpl/BaosongTpl.api'; import { findUserRightForTpl } from '../tpl/BaosongTpl.api';
import { useRoute,useRouter } from 'vue-router'; import { useRoute,useRouter } from 'vue-router';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
...@@ -55,26 +58,38 @@ onMounted(()=>{ ...@@ -55,26 +58,38 @@ onMounted(()=>{
const key = ref('tab1'); const key = ref('tab1');
const tabList = [
// 使用 computed 计算 tabList,根据 dataMap 中的记录数动态设置 disabled
const tabList = computed(() => {
const tabs = [
{ {
key: 'tab1', key: 'tab1',
tab: '年报', tab: '年报',
type: 1
}, },
{ {
key: 'tab2', key: 'tab2',
tab: '季报', tab: '季报',
type: 2
}, },
{ {
key: 'tab3', key: 'tab3',
tab: '月报', tab: '月报',
type: 3
}, },
{ {
key: 'tab4', key: 'tab4',
tab: '年度报告', tab: '年度报告',
type: 4
}, },
]; ];
return tabs.map(tab => ({
...tab,
disabled: !dataMap.value[tab.type] || dataMap.value[tab.type].length === 0
}));
});
const onTabChange = async (value: string) => { const onTabChange = async (value: string) => {
...@@ -92,75 +107,106 @@ const onTabChange = async (value: string) => { ...@@ -92,75 +107,106 @@ const onTabChange = async (value: string) => {
const gotoPage = async (item) => { const gotoPage = async (item) => {
let code = item.code; // 确保所有参数都设置完成后再跳转
queryParam.value.tplName = item.nm queryParam.value.tplName = item.nm || ''
queryParam.value.tplCode = item.code queryParam.value.tplCode = item.code || ''
queryParam.value.tplId = item.id queryParam.value.tplId = item.id || ''
let targetPath = ''
const code = item.code || ''
if(code === 'T-B-1') { if(code === 'T-B-1') {
ruterToPage('/baosong/report/components/Tb1') targetPath = '/baosong/report/components/Tb1'
} else if(code === 'T-B-2') { } else if(code === 'T-B-2') {
ruterToPage('/baosong/report/components/Tb2') targetPath = '/baosong/report/components/Tb2'
} else if(code === 'T-B-3') { } else if(code === 'T-B-3') {
ruterToPage('/baosong/report/components/Tb3') targetPath = '/baosong/report/components/Tb3'
} else if(code === 'T-B-4') { } else if(code === 'T-B-4') {
ruterToPage('/baosong/report/components/Tb4') targetPath = '/baosong/report/components/Tb4'
} else if(code === 'T-B-5') { } else if(code === 'T-B-5') {
ruterToPage('/baosong/report/components/Tb5') targetPath = '/baosong/report/components/Tb5'
} else if(code === 'T-B-6') { } else if(code === 'T-B-6') {
ruterToPage('/baosong/report/components/Tb6') targetPath = '/baosong/report/components/Tb6'
} else if(code === 'T-B-7') { } else if(code === 'T-B-7') {
ruterToPage('/baosong/report/components/Tb7') targetPath = '/baosong/report/components/Tb7'
} else if(code === 'T-B-8') { } else if(code === 'T-B-8') {
ruterToPage('/baosong/report/components/Tb8') targetPath = '/baosong/report/components/Tb8'
} else if(code === 'T-B-9') { } else if(code === 'T-B-9') {
ruterToPage('/baosong/report/components/Tb9') targetPath = '/baosong/report/components/Tb9'
} else if(code === 'T-B-10') { } else if(code === 'T-B-10') {
ruterToPage('/baosong/report/components/Tb10') targetPath = '/baosong/report/components/Tb10'
} else if(code === 'T-B-11') { } else if(code === 'T-B-11') {
ruterToPage('/baosong/report/components/Tb11') targetPath = '/baosong/report/components/Tb11'
} else if(code === 'R-R-1') { } else if(code === 'R-R-1') {
ruterToPage('/baosong/report/components/Rr1') targetPath = '/baosong/report/components/Rr1'
} else if(code === 'R-R-2') { } else if(code === 'R-R-2') {
ruterToPage('/baosong/report/components/Rr2') targetPath = '/baosong/report/components/Rr2'
} else if(code === 'T-M-1') { } else if(code === 'T-M-1') {
ruterToPage('/baosong/report/components/Tm1') targetPath = '/baosong/report/components/Tm1'
} else if(code === 'T-M-2') { } else if(code === 'T-M-2') {
ruterToPage('/baosong/report/components/Tm2') targetPath = '/baosong/report/components/Tm2'
} else if(code === 'T-M-3') { } else if(code === 'T-M-3') {
ruterToPage('/baosong/report/components/Tm3') targetPath = '/baosong/report/components/Tm3'
} else if(code === 'T-Q-1') { } else if(code === 'T-Q-1') {
ruterToPage('/baosong/report/components/Tq1') targetPath = '/baosong/report/components/Tq1'
} else if(code === 'T-Q-2') { } else if(code === 'T-Q-2') {
ruterToPage('/baosong/report/components/Tq2') targetPath = '/baosong/report/components/Tq2'
} else if(code === 'T-Q-3') { } else if(code === 'T-Q-3') {
ruterToPage('/baosong/report/components/Tq3') targetPath = '/baosong/report/components/Tq3'
} else if(code === 'T-Q-4') { } else if(code === 'T-Q-4') {
ruterToPage('/baosong/report/components/Tq4') targetPath = '/baosong/report/components/Tq4'
} else if(code === 'T-Q-5') { } else if(code === 'T-Q-5') {
ruterToPage('/baosong/report/components/Tq5') targetPath = '/baosong/report/components/Tq5'
}
if (targetPath) {
console.log('跳转到页面:', targetPath, '参数:', queryParam.value);
// 使用 Promise 确保数据更新完成后再跳转
await nextTick();
router.push({
path: targetPath,
query: {
taskId: queryParam.value.taskId,
taskName: queryParam.value.taskName,
tplId: queryParam.value.tplId,
tplName: queryParam.value.tplName,
tplCode: queryParam.value.tplCode
}
});
} }
} }
const dataList = ref([]) const dataList = ref([])
const dataMap = ref({})
const dataAllList = ref([]) const dataAllList = ref([])
async function iniData() { async function iniData() {
dataAllList.value = await allTpls({}); dataAllList.value = await findUserRightForTpl({});
dataList.value = await filteredData(1) dataMap.value = dataAllList.value.reduce((result, item) => {
const key = item.tp;
if (!result[key]) {
result[key] = [];
}
result[key].push(item);
return result;
}, {});
dataList.value = dataMap.value[1]
} }
const filteredData = (async (tp) => { const filteredData = (async (tp) => {
return dataAllList.value.filter(item => item.tp === tp); return dataMap.value[tp]
}); });
// 简化跳转函数,直接集成到 gotoPage 中
const ruterToPage = ((url) => { const ruterToPage = ((url) => {
router.push({path:url, query: { router.push({
path: url,
query: {
...queryParam.value ...queryParam.value
}}) }
})
return false return false
}) })
</script> </script>
\ No newline at end of file
...@@ -16,6 +16,7 @@ enum Api { ...@@ -16,6 +16,7 @@ enum Api {
importXml = '/baosong/baosongTpl/importXml', importXml = '/baosong/baosongTpl/importXml',
allTpls = '/baosong/baosongTpl/allTpls', allTpls = '/baosong/baosongTpl/allTpls',
importTplItemDes = '/baosong/baosongTpl/importTplItemDes', importTplItemDes = '/baosong/baosongTpl/importTplItemDes',
findUserRightForTpl = '/baosong/baosongTpl/findUserRightForTpl'
} }
/** /**
...@@ -43,6 +44,9 @@ export const list = (params) => ...@@ -43,6 +44,9 @@ export const list = (params) =>
export const allTpls = (params) => export const allTpls = (params) =>
defHttp.get({url: Api.allTpls, params}); defHttp.get({url: Api.allTpls, params});
export const findUserRightForTpl = (params) =>
defHttp.get({url: Api.findUserRightForTpl, params});
/** /**
* 删除单个 * 删除单个
*/ */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论