|
|
@@ -1,65 +1,62 @@
|
|
1
|
1
|
<script setup>
|
|
2
|
|
-import { getCurrentInstance, onActivated, onMounted, ref } from 'vue';
|
|
3
|
|
-import { onBeforeRouteUpdate, useRouter } from 'vue-router';
|
|
4
|
|
-import { useEmergencyStore } from '@/stores/emergencyManager.js';
|
|
5
|
|
-
|
|
6
|
|
-const emergencyInfo = useEmergencyStore()
|
|
7
|
|
-const {
|
|
8
|
|
- proxy
|
|
9
|
|
-} = getCurrentInstance()
|
|
|
2
|
+import { getCurrentInstance, ref } from 'vue';
|
|
|
3
|
+const { proxy } = getCurrentInstance();
|
|
10
|
4
|
|
|
11
|
5
|
/* 通用方法: 重置list数据 */
|
|
12
|
6
|
const basicReset = () => {
|
|
13
|
7
|
finished.value = false;
|
|
14
|
8
|
loading.value = true;
|
|
15
|
|
- pageNum.value = 1
|
|
16
|
|
- list.value = []
|
|
17
|
|
-}
|
|
18
|
|
-
|
|
19
|
|
-/* 返回上一级页面 */
|
|
20
|
|
-const router = useRouter()
|
|
|
9
|
+ pageNum.value = 1;
|
|
|
10
|
+ list.value = [];
|
|
|
11
|
+};
|
|
21
|
12
|
|
|
22
|
13
|
/* 查询数据 */
|
|
23
|
|
-const pageNum = ref(1)
|
|
24
|
|
-const pageSize = ref(10)
|
|
25
|
|
-const total = ref(0)
|
|
26
|
|
-const resultData = ref([])
|
|
|
14
|
+const pageNum = ref(1);
|
|
|
15
|
+const pageSize = ref(10);
|
|
|
16
|
+const total = ref(0);
|
|
|
17
|
+const resultData = ref([]);
|
|
27
|
18
|
const fetchData = ref({
|
|
28
|
|
- lawName:''
|
|
29
|
|
-})
|
|
|
19
|
+ lawName: '',
|
|
|
20
|
+ lawType: 'safe'
|
|
|
21
|
+});
|
|
30
|
22
|
|
|
31
|
23
|
const onSearch = () => {
|
|
32
|
|
- basicReset()
|
|
33
|
|
- onLoad()
|
|
34
|
|
-}
|
|
|
24
|
+ basicReset();
|
|
|
25
|
+ onLoad();
|
|
|
26
|
+};
|
|
35
|
27
|
|
|
36
|
28
|
const resetCondition = () => {
|
|
37
|
|
- basicReset()
|
|
38
|
|
- fetchData.value = {
|
|
39
|
|
- lawName:''
|
|
40
|
|
- }
|
|
41
|
|
- onLoad()
|
|
42
|
|
-}
|
|
|
29
|
+ basicReset();
|
|
|
30
|
+ fetchData.value.lawName = '';
|
|
|
31
|
+ onLoad();
|
|
|
32
|
+};
|
|
|
33
|
+
|
|
|
34
|
+const currentTab = ref('safe');
|
|
|
35
|
+const handleClick = (tab) => {
|
|
|
36
|
+ currentTab.value = tab;
|
|
|
37
|
+ fetchData.value.lawType = tab;
|
|
|
38
|
+ onRefresh();
|
|
|
39
|
+};
|
|
43
|
40
|
|
|
44
|
41
|
/* 查询请求 */
|
|
45
|
42
|
const queryFetch = async () => {
|
|
46
|
|
- if (sessionStorage.getItem("lawName")) {
|
|
47
|
|
- fetchData.value.lawName = sessionStorage.getItem("lawName")
|
|
48
|
|
- sessionStorage.removeItem("lawName")
|
|
|
43
|
+ if (sessionStorage.getItem('lawName')) {
|
|
|
44
|
+ fetchData.value.lawName = sessionStorage.getItem('lawName');
|
|
|
45
|
+ sessionStorage.removeItem('lawName');
|
|
49
|
46
|
}
|
|
50
|
|
- const url = '/sgsafe/InstitutionLaw/query'
|
|
|
47
|
+ const url = '/sgsafe/InstitutionLaw/query';
|
|
51
|
48
|
const param = {
|
|
52
|
49
|
page: pageNum.value,
|
|
53
|
50
|
rows: pageSize.value,
|
|
54
|
51
|
params: JSON.stringify(fetchData.value)
|
|
55
|
|
- }
|
|
|
52
|
+ };
|
|
56
|
53
|
try {
|
|
57
|
|
- const res = await proxy.$axios.post(url,param);
|
|
|
54
|
+ const res = await proxy.$axios.post(url, param);
|
|
58
|
55
|
if (res.data.code === 0) {
|
|
59
|
|
- total.value = res.data.data.total
|
|
60
|
|
- resultData.value = res.data.data.records
|
|
|
56
|
+ total.value = res.data.data.total;
|
|
|
57
|
+ resultData.value = res.data.data.records;
|
|
61
|
58
|
} else {
|
|
62
|
|
- console.log('操作失败!' + res.data.msg)
|
|
|
59
|
+ console.log('操作失败!' + res.data.msg);
|
|
63
|
60
|
}
|
|
64
|
61
|
} catch (error) {
|
|
65
|
62
|
console.error('请求出错:', error);
|
|
|
@@ -68,12 +65,12 @@ const queryFetch = async () => {
|
|
68
|
65
|
|
|
69
|
66
|
/* 列表加载与下拉刷新 */
|
|
70
|
67
|
const list = ref([]);
|
|
71
|
|
-const refreshing = ref(false)
|
|
72
|
|
-const loading = ref(false)
|
|
73
|
|
-const finished = ref(false)
|
|
|
68
|
+const refreshing = ref(false);
|
|
|
69
|
+const loading = ref(false);
|
|
|
70
|
+const finished = ref(false);
|
|
74
|
71
|
|
|
75
|
72
|
const onRefresh = () => {
|
|
76
|
|
- basicReset()
|
|
|
73
|
+ basicReset();
|
|
77
|
74
|
onLoad();
|
|
78
|
75
|
};
|
|
79
|
76
|
|
|
|
@@ -86,10 +83,10 @@ const onLoad = async () => {
|
|
86
|
83
|
try {
|
|
87
|
84
|
await queryFetch();
|
|
88
|
85
|
if (pageSize.value * pageNum.value < total.value) {
|
|
89
|
|
- list.value = [...list.value,...resultData.value ]
|
|
|
86
|
+ list.value = [...list.value, ...resultData.value];
|
|
90
|
87
|
pageNum.value++;
|
|
91
|
88
|
} else {
|
|
92
|
|
- list.value = [...list.value,...resultData.value ]
|
|
|
89
|
+ list.value = [...list.value, ...resultData.value];
|
|
93
|
90
|
finished.value = true;
|
|
94
|
91
|
}
|
|
95
|
92
|
} catch (error) {
|
|
|
@@ -101,27 +98,25 @@ const onLoad = async () => {
|
|
101
|
98
|
};
|
|
102
|
99
|
|
|
103
|
100
|
/* 在线预览实现 */
|
|
104
|
|
-import {Base64} from "js-base64";
|
|
|
101
|
+import { Base64 } from 'js-base64';
|
|
105
|
102
|
import { showFailToast } from 'vant';
|
|
106
|
|
-const linShiFid=ref({
|
|
107
|
|
- fileId:''
|
|
108
|
|
-})
|
|
|
103
|
+const linShiFid = ref({ fileId: '' });
|
|
109
|
104
|
const handlePreview = (fileId) => {
|
|
110
|
105
|
if (fetchData.value.lawName) {
|
|
111
|
|
- sessionStorage.setItem("lawName", fetchData.value.lawName)
|
|
|
106
|
+ sessionStorage.setItem('lawName', fetchData.value.lawName);
|
|
112
|
107
|
}
|
|
113
|
|
- linShiFid.value.fileId= fileId
|
|
114
|
|
- getTableDataQueryFile()
|
|
115
|
|
-}
|
|
116
|
|
-const bucket = ref(import.meta.env.VITE_BUCKET)
|
|
|
108
|
+ linShiFid.value.fileId = fileId;
|
|
|
109
|
+ getTableDataQueryFile();
|
|
|
110
|
+};
|
|
|
111
|
+const bucket = ref(import.meta.env.VITE_BUCKET);
|
|
117
|
112
|
const getTableDataQueryFile = () => {
|
|
118
|
|
- var url = 'framework/Common/queryFileWithValues'
|
|
119
|
|
- var param = {
|
|
120
|
|
- fId: linShiFid.value.fileId,
|
|
121
|
|
- }
|
|
|
113
|
+ const url = 'framework/Common/queryFileWithValues';
|
|
|
114
|
+ let param = {
|
|
|
115
|
+ fId: linShiFid.value.fileId
|
|
|
116
|
+ };
|
|
122
|
117
|
proxy.$axios.get(url, param).then(response => {
|
|
123
|
|
- if (response.data.code == 0) {
|
|
124
|
|
- const downloadPath = import.meta.env.VITE_BASE_API + '/framework/Common/downloadFileS3?bucket='+ bucket.value + '&id='
|
|
|
118
|
+ if (response.data.code === 0) {
|
|
|
119
|
+ const downloadPath = import.meta.env.VITE_BASE_API + '/framework/Common/downloadFileS3?bucket=' + bucket.value + '&id=';
|
|
125
|
120
|
const fileListWithUrls = response.data.data.map(file => ({
|
|
126
|
121
|
...file,
|
|
127
|
122
|
url: `${downloadPath}${file.id}`, // 添加完整的下载路径
|
|
|
@@ -131,23 +126,35 @@ const getTableDataQueryFile = () => {
|
|
131
|
126
|
id: file.id
|
|
132
|
127
|
}));
|
|
133
|
128
|
|
|
134
|
|
- var originUrl = import.meta.env.VITE_PREVIEW_BASE_API + 'framework/Common/downloadFileS3?bucket=' + bucket.value +'&id=' + fileListWithUrls[0].id
|
|
135
|
|
- var previewUrl = originUrl + '&fullfilename=' + Date.now() + fileListWithUrls[0].name
|
|
136
|
|
- var url = import.meta.env.VITE_PREVIEW_API + 'onlinePreview?url=' + encodeURIComponent(Base64.encode(
|
|
137
|
|
- previewUrl)) + '&officePreviewType=pdf'
|
|
|
129
|
+ let originUrl = import.meta.env.VITE_PREVIEW_BASE_API + 'framework/Common/downloadFileS3?bucket=' + bucket.value + '&id=' + fileListWithUrls[0].id;
|
|
|
130
|
+ let previewUrl = originUrl + '&fullfilename=' + Date.now() + fileListWithUrls[0].name;
|
|
|
131
|
+ let url = import.meta.env.VITE_PREVIEW_API + 'onlinePreview?url=' + encodeURIComponent(Base64.encode(
|
|
|
132
|
+ previewUrl)) + '&officePreviewType=pdf';
|
|
138
|
133
|
window.open(url);
|
|
139
|
134
|
} else {
|
|
140
|
|
- showFailToast('失败!' + response.data.msg)
|
|
|
135
|
+ showFailToast('失败!' + response.data.msg);
|
|
141
|
136
|
}
|
|
142
|
|
- })
|
|
143
|
|
-}
|
|
|
137
|
+ });
|
|
|
138
|
+};
|
|
144
|
139
|
|
|
145
|
140
|
</script>
|
|
146
|
141
|
|
|
147
|
142
|
<template>
|
|
148
|
143
|
<div class="page-container">
|
|
149
|
144
|
<van-sticky>
|
|
150
|
|
- <van-nav-bar title="法律法规" />
|
|
|
145
|
+ <van-nav-bar
|
|
|
146
|
+ title="法律法规"
|
|
|
147
|
+ @click-left="handleClick('safe')"
|
|
|
148
|
+ @click-right="handleClick('env')"
|
|
|
149
|
+ >
|
|
|
150
|
+ <template #left>
|
|
|
151
|
+ <div class="custom-tab" :class="{ 'custom-tab--active': currentTab === 'safe' }">安全</div>
|
|
|
152
|
+ </template>
|
|
|
153
|
+ <template #right>
|
|
|
154
|
+ <div class="custom-tab" :class="{ 'custom-tab--active': currentTab === 'env' }">环保</div>
|
|
|
155
|
+ </template>
|
|
|
156
|
+ </van-nav-bar>
|
|
|
157
|
+
|
|
151
|
158
|
<van-search
|
|
152
|
159
|
v-model="fetchData.lawName"
|
|
153
|
160
|
@search="onSearch"
|
|
|
@@ -208,15 +215,32 @@ const getTableDataQueryFile = () => {
|
|
208
|
215
|
background-color: #fff;
|
|
209
|
216
|
}
|
|
210
|
217
|
|
|
211
|
|
-.label-content {
|
|
212
|
|
- display: flex;
|
|
213
|
|
- flex-direction: column;
|
|
214
|
|
- gap: 4px;
|
|
215
|
|
-}
|
|
216
|
|
-
|
|
217
|
218
|
.bold-title {
|
|
218
|
219
|
font-weight: bold;
|
|
219
|
220
|
color: #333;
|
|
220
|
221
|
}
|
|
221
|
222
|
|
|
|
223
|
+.custom-tab {
|
|
|
224
|
+ padding: 8px 0;
|
|
|
225
|
+ font-size: 14px;
|
|
|
226
|
+ color: var(--van-gray-7, #646566);
|
|
|
227
|
+ position: relative;
|
|
|
228
|
+ cursor: pointer;
|
|
|
229
|
+}
|
|
|
230
|
+
|
|
|
231
|
+.custom-tab--active {
|
|
|
232
|
+ color: var(--van-primary-color, #1989fa);
|
|
|
233
|
+}
|
|
|
234
|
+
|
|
|
235
|
+.custom-tab--active::after {
|
|
|
236
|
+ content: '';
|
|
|
237
|
+ position: absolute;
|
|
|
238
|
+ bottom: 0;
|
|
|
239
|
+ left: 0;
|
|
|
240
|
+ width: 100%;
|
|
|
241
|
+ height: 3px;
|
|
|
242
|
+ background-color: var(--van-primary-color, #1989fa);
|
|
|
243
|
+ border-radius: 2px;
|
|
|
244
|
+}
|
|
|
245
|
+
|
|
222
|
246
|
</style>
|