|
@@ -0,0 +1,410 @@
|
|
|
+<script setup name="sharedDetail">
|
|
|
+import {nextTick, onMounted, ref, computed, getCurrentInstance} from 'vue'
|
|
|
+import { useRoute, useRouter } from "vue-router";
|
|
|
+import apiSheet from '@/api/sheet'
|
|
|
+import { useWindowSize } from '@vueuse/core'
|
|
|
+import { showToast, showDialog } from "vant";
|
|
|
+import {usePublicSettingStore} from '@/store/modules/publicSetting'
|
|
|
+const publicSettingStore = usePublicSettingStore()
|
|
|
+// import { useDownLoadFile } from '@/hooks/useDownLoadFile'
|
|
|
+const { appContext : { config: { globalProperties } } } = getCurrentInstance();
|
|
|
+const { width } = useWindowSize()
|
|
|
+const route = useRoute()
|
|
|
+const router = useRouter()
|
|
|
+const queryData = ref({})
|
|
|
+const link = ref(publicSettingStore.publicSetting.ChartViewUrl);
|
|
|
+//显示更多操作栏
|
|
|
+let showMoreAction = ref(false)
|
|
|
+let showPicker = ref(false)
|
|
|
+let showVersionPicker = ref(false)
|
|
|
+const sheetActions = computed(() => {
|
|
|
+ return [
|
|
|
+ { label: globalProperties.$t('shared_table.refresh'), types:'flushed'},
|
|
|
+ { label: globalProperties.$t('shared_table.download'), types:'download'},
|
|
|
+ { label: globalProperties.$t('shared_table.delete'), types:'delete'},
|
|
|
+ { label: globalProperties.$t('shared_table.cancel'), types:'cancel'},
|
|
|
+ ]
|
|
|
+})
|
|
|
+
|
|
|
+const downExcelFileUrl = computed(() => {
|
|
|
+ let url = `${
|
|
|
+ import.meta.env.VITE_APP_API_URL
|
|
|
+ }/datamanage/excel_info/table/download?${localStorage.getItem("token")}`;
|
|
|
+ return url;
|
|
|
+})
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getExcelDetail( 'load' )
|
|
|
+ getVersionList()
|
|
|
+ getChildTable()
|
|
|
+})
|
|
|
+//获取表格列表
|
|
|
+async function getExcelDetail( source = 'refresh', ExcelInfoId = '' ){
|
|
|
+ const detailReq = {
|
|
|
+ ExcelInfoId: route.query.id,
|
|
|
+ }
|
|
|
+ if(source==='delete') detailReq.ExcelInfoId = ExcelInfoId
|
|
|
+ const res = await apiSheet.excelDetail(detailReq)
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ if(source==='refresh') showToast({ type: 'success', message: globalProperties.$t('shared_table.refresh_success') })
|
|
|
+ queryData.value = res.Data
|
|
|
+}
|
|
|
+
|
|
|
+//更多操作
|
|
|
+function handleActionClick(item){
|
|
|
+ switch(item.types){
|
|
|
+ case 'flushed':
|
|
|
+ getExcelDetail( 'refresh' )
|
|
|
+ showMoreAction.value = false
|
|
|
+ break;
|
|
|
+ case 'download':
|
|
|
+ downloadExcel(queryData.value)
|
|
|
+ showMoreAction.value = false
|
|
|
+ break;
|
|
|
+ case 'delete':
|
|
|
+ showDialog({
|
|
|
+ title: globalProperties.$t('shared_table.note'),
|
|
|
+ message: globalProperties.$t('shared_table.once_deleted'),
|
|
|
+ showCancelButton: true
|
|
|
+ }).then(() => {
|
|
|
+ apiSheet.excelDelete({
|
|
|
+ ExcelClassifyId: queryData.value.ExcelClassifyId,
|
|
|
+ ExcelInfoId: queryData.value.ExcelInfoId,
|
|
|
+ Source: queryData.Source,
|
|
|
+ }).then(res=>{
|
|
|
+ if(res.Ret!==200) return
|
|
|
+ showToast({message: globalProperties.$t('shared_table.deletion_success'),type:'success'})
|
|
|
+ showMoreAction.value = false
|
|
|
+ getExcelDetail('delete', res.Data.ExcelInfoId)
|
|
|
+ })
|
|
|
+ }).catch(()=>{})
|
|
|
+ break;
|
|
|
+ case 'cancel':
|
|
|
+ showMoreAction.value = false
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/* 下载数据 */
|
|
|
+function downloadExcel(cell) {
|
|
|
+ const { Source, FileUrl, ExcelInfoId, ExcelName } = cell;
|
|
|
+ console.log(cell);
|
|
|
+
|
|
|
+ let value = "";
|
|
|
+ if (Source === 1) {
|
|
|
+ handleDownloadResource(FileUrl, ExcelName)
|
|
|
+ } else if ([2, 3,5].includes(Source)) {
|
|
|
+ value = `${downExcelFileUrl.value}&ExcelInfoId=${ExcelInfoId}`;
|
|
|
+ console.log(value);
|
|
|
+
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.href = value;
|
|
|
+ a.target = "_blank";
|
|
|
+ a.download = ExcelName;
|
|
|
+ a.style.display = "none";
|
|
|
+ document.body.append(a);
|
|
|
+ a.click();
|
|
|
+ }
|
|
|
+}
|
|
|
+// 下载文件
|
|
|
+function handleDownloadResource(url,fileName,successCb,faileCb){
|
|
|
+ const b = new Base64()
|
|
|
+ const arr = url.split('/')
|
|
|
+ const _fileName = arr[arr.length-1]
|
|
|
+ const fileNameTypeArr = fileName.split('.')
|
|
|
+ const _fileNameTypeArr = _fileName.split('.')
|
|
|
+ const fileNameType = fileNameTypeArr.length > 1 ? fileNameTypeArr[fileNameTypeArr.length-1] : ''
|
|
|
+ const _fileNameType = _fileNameTypeArr.length > 1 ? _fileNameTypeArr[_fileNameTypeArr.length-1] : ''
|
|
|
+ apiSheet.apiDownloadResource({
|
|
|
+ FileName:/* fileName||_fileName */'',
|
|
|
+ FileUrl:b.encode(url)
|
|
|
+ }).then(res=>{
|
|
|
+ //bus.$parseData(response);
|
|
|
+ const content = res
|
|
|
+ const blob = new Blob([content])
|
|
|
+ console.log(blob);
|
|
|
+
|
|
|
+ if ('download' in document.createElement('a')) {
|
|
|
+ const elink = document.createElement('a')
|
|
|
+ elink.download = fileNameType?fileName:(fileName+'.'+_fileNameType)
|
|
|
+ elink.style.display = 'none'
|
|
|
+ elink.href = window.URL.createObjectURL(blob)
|
|
|
+ document.body.appendChild(elink)
|
|
|
+ elink.click()
|
|
|
+ window.URL.revokeObjectURL(elink.href)
|
|
|
+ document.body.removeChild(elink)
|
|
|
+ } else {
|
|
|
+ navigator.msSaveBlob(blob, fileNameType?fileName:(fileName+'.'+_fileNameType))
|
|
|
+ }
|
|
|
+ successCb&&successCb()
|
|
|
+ }).catch(()=>{
|
|
|
+ showToast({message: '下载失败',type:'warning'})
|
|
|
+ faileCb&&faileCb()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function Base64() {
|
|
|
+ // private property
|
|
|
+ var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
|
+ // public method for encoding
|
|
|
+ this.encode = function (input) {
|
|
|
+ var output = "";
|
|
|
+ var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
|
|
+ var i = 0;
|
|
|
+ input = this._utf8_encode(input);
|
|
|
+ while (i < input.length) {
|
|
|
+ chr1 = input.charCodeAt(i++);
|
|
|
+ chr2 = input.charCodeAt(i++);
|
|
|
+ chr3 = input.charCodeAt(i++);
|
|
|
+ enc1 = chr1 >> 2;
|
|
|
+ enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
|
|
+ enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
|
|
+ enc4 = chr3 & 63;
|
|
|
+ if (isNaN(chr2)) {
|
|
|
+ enc3 = enc4 = 64;
|
|
|
+ } else if (isNaN(chr3)) {
|
|
|
+ enc4 = 64;
|
|
|
+ }
|
|
|
+ output = output +
|
|
|
+ _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
|
|
|
+ _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
|
|
|
+ }
|
|
|
+ return output;
|
|
|
+ }
|
|
|
+ // private method for UTF-8 encoding
|
|
|
+ this._utf8_encode = function (string) {
|
|
|
+ string = string.replace(/\r\n/g, "\n");
|
|
|
+ var utftext = "";
|
|
|
+ for (var n = 0; n < string.length; n++) {
|
|
|
+ var c = string.charCodeAt(n);
|
|
|
+ if (c < 128) {
|
|
|
+ utftext += String.fromCharCode(c);
|
|
|
+ } else if ((c > 127) && (c < 2048)) {
|
|
|
+ utftext += String.fromCharCode((c >> 6) | 192);
|
|
|
+ utftext += String.fromCharCode((c & 63) | 128);
|
|
|
+ } else {
|
|
|
+ utftext += String.fromCharCode((c >> 12) | 224);
|
|
|
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
|
|
+ utftext += String.fromCharCode((c & 63) | 128);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return utftext;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const columns = [
|
|
|
+ { text: '杭州', value: 'Hangzhou' },
|
|
|
+ { text: '宁波', value: 'Ningbo' },
|
|
|
+ { text: '温州', value: 'Wenzhou' },
|
|
|
+ { text: '绍兴', value: 'Shaoxing' },
|
|
|
+ { text: '湖州', value: 'Huzhou' },
|
|
|
+];
|
|
|
+const versionOpts = ref([])
|
|
|
+const childTableOpts = ref([])
|
|
|
+const fieldValue = ref('平衡表');
|
|
|
+const fieldValueVersion = ref('平衡表');
|
|
|
+
|
|
|
+// 平衡表获取版本列表
|
|
|
+function getVersionList(){
|
|
|
+ apiSheet.balanceTableVersion({ExcelInfoId: route.query.id,}).then(res=>{
|
|
|
+ if(res.Ret === 200){
|
|
|
+ const arr = res.Data.List || []
|
|
|
+ versionOpts.value = arr
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 平衡表获取子表列表
|
|
|
+function getChildTable(){
|
|
|
+ apiSheet.getBalanceChildTable({ParentId: route.query.id,}).then(res=>{
|
|
|
+ if(res.Ret === 200){
|
|
|
+ const arr = res.Data.List || []
|
|
|
+ childTableOpts.value = arr
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+// 平衡表选择器
|
|
|
+const onConfirm = ({ selectedOptions }) => {
|
|
|
+ showPicker.value = false;
|
|
|
+ fieldValue.value = selectedOptions[0].text;
|
|
|
+};
|
|
|
+
|
|
|
+// 版本选择器
|
|
|
+const onConfirmVersion = ({ selectedOptions }) => {
|
|
|
+ showVersionPicker.value = false;
|
|
|
+ fieldValueVersion.value = selectedOptions[0].text;
|
|
|
+};
|
|
|
+
|
|
|
+// 关联图表页
|
|
|
+function goChart () {
|
|
|
+ router.push({ path: '/balance/chart', query: { id: queryData.value.ExcelInfoId } });
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="page">
|
|
|
+ <div class="filter-box">
|
|
|
+ <div class="filter-item">
|
|
|
+ <div class="filter-label">平衡表</div>
|
|
|
+ <div class="filter-select" @click.stop="showPicker=true">{{ fieldValue }} <van-icon name="arrow-down"/></div>
|
|
|
+ </div>
|
|
|
+ <div class="filter-item">
|
|
|
+ <div class="filter-label version">版本</div>
|
|
|
+ <div class="filter-select" @click.stop="showVersionPicker=true">{{ fieldValueVersion }} <van-icon name="arrow-down"/></div>
|
|
|
+ </div>
|
|
|
+ <div class="top-item"><van-icon name="chart-trending-o" size="22" @click.stop="goChart"v-if="queryData.Source === 5" /> <van-icon name="more-o" size="22" @click.stop="showMoreAction=true"/></div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="top-box">
|
|
|
+ <div class="top-item">{{ $t('shared_table.author') }}:{{ queryData.SysUserRealName }}</div>
|
|
|
+ <div class="top-item">{{ $t('shared_table.recent_save_time') }}:{{ queryData.CreateTime?.slice(0,10) }}</div>
|
|
|
+ </div>
|
|
|
+ <div class="sheet-box" v-if="queryData.UniqueCode">
|
|
|
+ <iframe :src="link + '/sheetshow?code=' + queryData.UniqueCode" frameborder="0" width="100%" height="100%"></iframe>
|
|
|
+ </div>
|
|
|
+ <!-- 更多设置弹窗 -->
|
|
|
+ <van-popup
|
|
|
+ v-model:show="showMoreAction"
|
|
|
+ :position="width>650?'center':'bottom'"
|
|
|
+ round
|
|
|
+ closeable
|
|
|
+ :style="width>650?{ width: '400px'}:''"
|
|
|
+ >
|
|
|
+ <div class="global-pop-wrap_mobile sheet-more-action-wrap">
|
|
|
+ <div class="head-box">
|
|
|
+ <div class="title van-ellipsis">{{queryData.ExcelName}}</div>
|
|
|
+ </div>
|
|
|
+ <div class="action-box">
|
|
|
+ <template v-for="item in sheetActions" :key="item.types">
|
|
|
+ <div class="action-item" @click="handleActionClick(item)">
|
|
|
+ {{item.label}}
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </van-popup>
|
|
|
+
|
|
|
+ <!-- 平衡表选择器 -->
|
|
|
+ <van-popup v-model:show="showPicker" round position="bottom">
|
|
|
+ <van-picker
|
|
|
+ :columns="childTableOpts"
|
|
|
+ @cancel="showPicker = false"
|
|
|
+ @confirm="onConfirm"
|
|
|
+ />
|
|
|
+ </van-popup>
|
|
|
+ <!-- 版本选择器 -->
|
|
|
+ <van-popup v-model:show="showVersionPicker" round position="bottom">
|
|
|
+ <van-picker
|
|
|
+ :columns="versionOpts"
|
|
|
+ @cancel="showVersionPicker = false"
|
|
|
+ @confirm="onConfirmVersion"
|
|
|
+ />
|
|
|
+ </van-popup>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.page{
|
|
|
+ width: 100%;
|
|
|
+ height: 100vh;
|
|
|
+ padding: 24px;
|
|
|
+ .filter-box {
|
|
|
+ font-size: 28px;
|
|
|
+ width: 100%;
|
|
|
+ height: 60px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ .filter-item {
|
|
|
+ width: 42%;
|
|
|
+ height: 60px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ .filter-label {
|
|
|
+ width: 30%;
|
|
|
+ height: 60px;
|
|
|
+ line-height: 60px;
|
|
|
+ color: #303133;
|
|
|
+ }
|
|
|
+ .version {
|
|
|
+ width: 20%;
|
|
|
+ }
|
|
|
+ .filter-select {
|
|
|
+ width: 70%;
|
|
|
+ height: 60px;
|
|
|
+ line-height: 60px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ border-radius: 4px;
|
|
|
+ padding: 0 12px;
|
|
|
+ // border: #303133 1px solid;
|
|
|
+ border: 1px solid rgba(200, 205, 217, 1)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .top-item {
|
|
|
+ width: 10%;
|
|
|
+ height: 60px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-around;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .top-box {
|
|
|
+ width: 100%;
|
|
|
+ height: 60px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ .top-item {
|
|
|
+ line-height: 60px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .sheet-box{
|
|
|
+ width: 100%;
|
|
|
+ height: calc(100% - 60px);
|
|
|
+ // background-color: pink;
|
|
|
+ }
|
|
|
+ .sheet-more-action-wrap{
|
|
|
+ .head-box{
|
|
|
+ .title{
|
|
|
+ width: 100%;
|
|
|
+ padding:34px 100px;
|
|
|
+ box-sizing: border-box;
|
|
|
+ font-size: 36px;
|
|
|
+ font-weight: 600;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .action-box{
|
|
|
+ .action-item{
|
|
|
+ text-align: center;
|
|
|
+ padding:32px 84px;
|
|
|
+ border-bottom: 1px solid #DCDFE6;
|
|
|
+ &:last-child{
|
|
|
+ border-bottom: none;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @media screen and (min-width: 650px) {
|
|
|
+ .filter-box {
|
|
|
+ font-size: 16px;
|
|
|
+ height: 30px;
|
|
|
+ .filter-item {
|
|
|
+ height: 30px;
|
|
|
+ .filter-label {
|
|
|
+ height: 30px;
|
|
|
+ line-height: 30px;
|
|
|
+ }
|
|
|
+ .filter-select {
|
|
|
+ height: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .top-item {
|
|
|
+ height: 30px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|