修改查看数据的接口
Showing
7 changed files
with
66 additions
and
5 deletions
| ... | @@ -54,6 +54,12 @@ export const downloadTableData = (params) => request({ | ... | @@ -54,6 +54,12 @@ export const downloadTableData = (params) => request({ |
| 54 | responseType: 'blob' | 54 | responseType: 'blob' |
| 55 | }); | 55 | }); |
| 56 | 56 | ||
| 57 | /** 数据使用中查看资产表的数据 */ | ||
| 58 | export const queryUseData = (params) => request({ | ||
| 59 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/contract-use/read?userGuid=${params.userGuid}&subjectGuid=${params.subjectGuid}`, | ||
| 60 | method: 'get' | ||
| 61 | }); | ||
| 62 | |||
| 57 | /** 分发连接器 */ | 63 | /** 分发连接器 */ |
| 58 | export const distributeContract = (params) => request({ | 64 | export const distributeContract = (params) => request({ |
| 59 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/contract-use/distribute`, | 65 | url: `${import.meta.env.VITE_APP_DIGITAL_CONTRACT_URL}/contract-use/distribute`, | ... | ... |
| ... | @@ -8,7 +8,7 @@ import router from './router' | ... | @@ -8,7 +8,7 @@ import router from './router' |
| 8 | import useSettingsStore from './store/modules/settings'; | 8 | import useSettingsStore from './store/modules/settings'; |
| 9 | import sysConfigStore from '@/store/modules/sysConfig' | 9 | import sysConfigStore from '@/store/modules/sysConfig' |
| 10 | import { ElMessage } from "element-plus" | 10 | import { ElMessage } from "element-plus" |
| 11 | import { openMessageBox } from "@/utils/common" | 11 | import { getPublicIP, openMessageBox } from "@/utils/common" |
| 12 | 12 | ||
| 13 | // pinia设置 | 13 | // pinia设置 |
| 14 | import { createPinia } from 'pinia' | 14 | import { createPinia } from 'pinia' |
| ... | @@ -66,6 +66,11 @@ const initApp = async () => { | ... | @@ -66,6 +66,11 @@ const initApp = async () => { |
| 66 | app.config.globalProperties.$ElMessage = ElMessage; // 全局消息提示 | 66 | app.config.globalProperties.$ElMessage = ElMessage; // 全局消息提示 |
| 67 | app.config.globalProperties.$openMessageBox = openMessageBox; // 二次确认提示对话框。 | 67 | app.config.globalProperties.$openMessageBox = openMessageBox; // 二次确认提示对话框。 |
| 68 | app.mount('#main-app') | 68 | app.mount('#main-app') |
| 69 | |||
| 70 | getPublicIP().then((ip) => { | ||
| 71 | localStorage.setItem('ipAddress', ip); | ||
| 72 | }) | ||
| 73 | |||
| 69 | } catch (error) { | 74 | } catch (error) { |
| 70 | console.error('应用初始化失败:', error); | 75 | console.error('应用初始化失败:', error); |
| 71 | // 这里可以添加一些错误处理逻辑,比如显示错误提示给用户 | 76 | // 这里可以添加一些错误处理逻辑,比如显示错误提示给用户 | ... | ... |
| ... | @@ -1207,3 +1207,22 @@ export const transferFlowLimit = (v, unit) => { //将时间统一转化为分钟 | ... | @@ -1207,3 +1207,22 @@ export const transferFlowLimit = (v, unit) => { //将时间统一转化为分钟 |
| 1207 | return v * 60; | 1207 | return v * 60; |
| 1208 | } | 1208 | } |
| 1209 | } | 1209 | } |
| 1210 | |||
| 1211 | /** 获取当前用户的IP地址 */ | ||
| 1212 | export const getPublicIP = async (): Promise<string> => { | ||
| 1213 | try { | ||
| 1214 | // 方法1:使用 fetch | ||
| 1215 | const response = await fetch('https://api64.ipify.org?format=json') | ||
| 1216 | const data = await response.json() | ||
| 1217 | return data.ip | ||
| 1218 | } catch (error) { | ||
| 1219 | try { | ||
| 1220 | // 方法2:备用 API | ||
| 1221 | const response = await fetch('https://api.ipify.org?format=json') | ||
| 1222 | const data = await response.json() | ||
| 1223 | return data.ip | ||
| 1224 | } catch (error2) { | ||
| 1225 | throw new Error('无法获取 IP 地址') | ||
| 1226 | } | ||
| 1227 | } | ||
| 1228 | } | ... | ... |
| ... | @@ -39,6 +39,7 @@ service.interceptors.request.use( | ... | @@ -39,6 +39,7 @@ service.interceptors.request.use( |
| 39 | "Content-Type": "multipart/form-data", | 39 | "Content-Type": "multipart/form-data", |
| 40 | }); | 40 | }); |
| 41 | config.headers.Authorization = localStorage.getItem('token'); | 41 | config.headers.Authorization = localStorage.getItem('token'); |
| 42 | config.headers['x-real-ip'] = localStorage.getItem('ipAddress'); | ||
| 42 | return config; | 43 | return config; |
| 43 | } | 44 | } |
| 44 | if (config.method == "postjsond") { | 45 | if (config.method == "postjsond") { |
| ... | @@ -48,16 +49,19 @@ service.interceptors.request.use( | ... | @@ -48,16 +49,19 @@ service.interceptors.request.use( |
| 48 | }); | 49 | }); |
| 49 | config.data = JSON.stringify(config.data); | 50 | config.data = JSON.stringify(config.data); |
| 50 | config.headers.Authorization = localStorage.getItem('token'); | 51 | config.headers.Authorization = localStorage.getItem('token'); |
| 52 | config.headers['x-real-ip'] = localStorage.getItem('ipAddress'); | ||
| 51 | return config; | 53 | return config; |
| 52 | } | 54 | } |
| 53 | if (config.responseType == "blob") { | 55 | if (config.responseType == "blob") { |
| 54 | // 文件流,文件名称相同时会判定同一个请求。 | 56 | // 文件流,文件名称相同时会判定同一个请求。 |
| 55 | const userStore = useUserStore(); | 57 | const userStore = useUserStore(); |
| 56 | config.headers.Authorization = localStorage.getItem('token'); | 58 | config.headers.Authorization = localStorage.getItem('token'); |
| 59 | config.headers['x-real-ip'] = localStorage.getItem('ipAddress'); | ||
| 57 | return config; | 60 | return config; |
| 58 | } | 61 | } |
| 59 | if (config.method === 'obsuploadrequest') { | 62 | if (config.method === 'obsuploadrequest') { |
| 60 | config.method = 'put'; | 63 | config.method = 'put'; |
| 64 | config.headers['x-real-ip'] = localStorage.getItem('ipAddress'); | ||
| 61 | return config; | 65 | return config; |
| 62 | } | 66 | } |
| 63 | // /** | 67 | // /** |
| ... | @@ -77,6 +81,7 @@ service.interceptors.request.use( | ... | @@ -77,6 +81,7 @@ service.interceptors.request.use( |
| 77 | /** 若是门户的url,则不做重复请求处理,会出现不同标签页都需要查同一个字典参数列表的 */ | 81 | /** 若是门户的url,则不做重复请求处理,会出现不同标签页都需要查同一个字典参数列表的 */ |
| 78 | if (config.url.indexOf('/portal/portal')) { | 82 | if (config.url.indexOf('/portal/portal')) { |
| 79 | config.headers.Authorization = localStorage.getItem('token'); | 83 | config.headers.Authorization = localStorage.getItem('token'); |
| 84 | config.headers['x-real-ip'] = localStorage.getItem('ipAddress'); | ||
| 80 | return config; | 85 | return config; |
| 81 | } | 86 | } |
| 82 | /** | 87 | /** |
| ... | @@ -113,6 +118,7 @@ service.interceptors.request.use( | ... | @@ -113,6 +118,7 @@ service.interceptors.request.use( |
| 113 | }); | 118 | }); |
| 114 | 119 | ||
| 115 | config.headers.Authorization = localStorage.getItem('token'); | 120 | config.headers.Authorization = localStorage.getItem('token'); |
| 121 | config.headers['x-real-ip'] = localStorage.getItem('ipAddress'); | ||
| 116 | return config; | 122 | return config; |
| 117 | }; | 123 | }; |
| 118 | /** 若是刷新token的请求,则不需要等refreshToken完成。 */ | 124 | /** 若是刷新token的请求,则不需要等refreshToken完成。 */ | ... | ... |
| ... | @@ -11,6 +11,9 @@ import { calcColumnWidth } from "@/utils/index"; | ... | @@ -11,6 +11,9 @@ import { calcColumnWidth } from "@/utils/index"; |
| 11 | import Moment from 'moment'; | 11 | import Moment from 'moment'; |
| 12 | import { TableColumnWidth } from "@/utils/enum"; | 12 | import { TableColumnWidth } from "@/utils/enum"; |
| 13 | import { ElMessage } from "element-plus"; | 13 | import { ElMessage } from "element-plus"; |
| 14 | import { | ||
| 15 | queryUseData | ||
| 16 | } from "@/api/modules/dataDelivery"; | ||
| 14 | 17 | ||
| 15 | const { proxy } = getCurrentInstance() as any; | 18 | const { proxy } = getCurrentInstance() as any; |
| 16 | 19 | ||
| ... | @@ -24,6 +27,20 @@ const tableFields: any = ref([]); | ... | @@ -24,6 +27,20 @@ const tableFields: any = ref([]); |
| 24 | const getData = () => { | 27 | const getData = () => { |
| 25 | tableData.value = []; | 28 | tableData.value = []; |
| 26 | tableDataLoading.value = true; | 29 | tableDataLoading.value = true; |
| 30 | if (route.query.useGuid) { | ||
| 31 | queryUseData({ | ||
| 32 | userGuid: route.query.useGuid, | ||
| 33 | subjectGuid: route.query.guid | ||
| 34 | }).then((res: any) => { | ||
| 35 | tableDataLoading.value = false; | ||
| 36 | if (res.code == proxy.$passCode) { | ||
| 37 | tableData.value = res.data.datas || []; | ||
| 38 | tableFields.value = res.data.fields || []; | ||
| 39 | } else { | ||
| 40 | ElMessage.error(res.msg); | ||
| 41 | } | ||
| 42 | }); | ||
| 43 | } else { | ||
| 27 | queryData(route.query.guid).then((res: any) => { | 44 | queryData(route.query.guid).then((res: any) => { |
| 28 | tableDataLoading.value = false; | 45 | tableDataLoading.value = false; |
| 29 | if (res.code == proxy.$passCode) { | 46 | if (res.code == proxy.$passCode) { |
| ... | @@ -33,6 +50,7 @@ const getData = () => { | ... | @@ -33,6 +50,7 @@ const getData = () => { |
| 33 | ElMessage.error(res.msg); | 50 | ElMessage.error(res.msg); |
| 34 | } | 51 | } |
| 35 | }); | 52 | }); |
| 53 | } | ||
| 36 | } | 54 | } |
| 37 | 55 | ||
| 38 | const getTextAlign = (field) => { | 56 | const getTextAlign = (field) => { | ... | ... |
| ... | @@ -56,7 +56,13 @@ const tableFields = ref([ | ... | @@ -56,7 +56,13 @@ const tableFields = ref([ |
| 56 | } | 56 | } |
| 57 | }, | 57 | }, |
| 58 | { | 58 | { |
| 59 | label: "合约名称", field: "contractName", width: 170, type: "text_btn", columClass: 'text_btn', value: "detail1", click: (scope) => { | 59 | label: "合约名称", field: "contractName", width: 170, type: "text_btn", columClass: 'text_btn', value: "detail1", disabled: (scope) => { |
| 60 | return scope.row.isDistribute == 'N'; | ||
| 61 | }, click: (scope) => { | ||
| 62 | let isDistribute = scope.row.isDistribute; | ||
| 63 | if (isDistribute == 'N') { | ||
| 64 | return; | ||
| 65 | } | ||
| 60 | //履约中的合约状态 | 66 | //履约中的合约状态 |
| 61 | router.push({ | 67 | router.push({ |
| 62 | name: 'smartContractDetail', | 68 | name: 'smartContractDetail', | ... | ... |
| ... | @@ -443,7 +443,8 @@ const handleTableViewData = (scope) => { | ... | @@ -443,7 +443,8 @@ const handleTableViewData = (scope) => { |
| 443 | query: { | 443 | query: { |
| 444 | guid: row.guid, | 444 | guid: row.guid, |
| 445 | name: row.tableChName, | 445 | name: row.tableChName, |
| 446 | damName: detailInfo.value.damName | 446 | damName: detailInfo.value.damName, |
| 447 | useGuid: route.query.useGuid | ||
| 447 | } | 448 | } |
| 448 | }); | 449 | }); |
| 449 | } | 450 | } |
| ... | @@ -1487,8 +1488,8 @@ const respParamsTableInfo = ref({ | ... | @@ -1487,8 +1488,8 @@ const respParamsTableInfo = ref({ |
| 1487 | <el-table-column label="操作" v-if="!detailInfo?.nodeId || foundMode == 'download'" minWidth="120px" align="left" fixed="right" show-overflow-tooltip> | 1488 | <el-table-column label="操作" v-if="!detailInfo?.nodeId || foundMode == 'download'" minWidth="120px" align="left" fixed="right" show-overflow-tooltip> |
| 1488 | <template #default="scope"> | 1489 | <template #default="scope"> |
| 1489 | <span class="text_btn" @click="handleTableViewData(scope)">查看样例数据</span> | 1490 | <span class="text_btn" @click="handleTableViewData(scope)">查看样例数据</span> |
| 1490 | <el-divider direction="vertical" /> | 1491 | <el-divider v-show="foundMode == 'download'" direction="vertical" /> |
| 1491 | <span class="text_btn" @click="handleTableViewDataDown(scope)">下载数据</span> | 1492 | <span v-show="foundMode == 'download'" class="text_btn" @click="handleTableViewDataDown(scope)">下载数据</span> |
| 1492 | </template> | 1493 | </template> |
| 1493 | </el-table-column> | 1494 | </el-table-column> |
| 1494 | </el-table> | 1495 | </el-table> | ... | ... |
-
Please register or sign in to post a comment