tanghaolin
8 天以前 9bee4f48db0c5b99b5683545fac737856d94d082
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<template>
  <!-- 系列文档 -->
  <div class="tableBox">
    <el-table border :max-height="state.tableHeight" stripe :data="state.m_fileList" style="width: 100%"
      :empty-text="t('ebookPage.noData.TR')">
      <el-table-column align="center" header-align="center" width="100" :label="t('ebookPage.operation.TR')">
        <template #default="scope">
          <!-- <el-button link size="small" type="primary" icon="Download" @click="downloadFile(scope.$index, scope.row)">{{
            t("ebookPage.download.TR") }}</el-button> -->
          <div @click="downloadFile(scope.$index, scope.row)" class="download-style"><el-icon>
              <Download />
            </el-icon> {{ t("ebookPage.download.TR") }}</div>
        </template>
      </el-table-column>
      <el-table-column align="center" header-align="center" width="180" property="AttachType"
        :label="t('ebookPage.type.TR')"></el-table-column>
      <el-table-column align="center" header-align="center" width="180" property="Name"
        :label="t('ebookPage.name.TR')"></el-table-column>
      <el-table-column align="center" header-align="center" width="140" property="UploadTime"
        :label="t('ebookPage.updateTime.TR')"></el-table-column>
      <el-table-column align="center" header-align="center" width="60" property="Version"
        :label="t('ebookPage.version.TR')"></el-table-column>
      <el-table-column align="center" width="120" header-align="center" property="Language"
        :label="t('ebookPage.lang.TR')"></el-table-column>
      <el-table-column width="100" align="center" header-align="center" property="FileSize"
        :label="t('ebookPage.size.TR')"></el-table-column>
      <el-table-column header-align="center" property="Description" :label="t('ebookPage.desc.TR')"></el-table-column>
    </el-table>
  </div>
</template>
 
<script setup name="attachFile">
import axiosHelper from "@/utils/axiosHelper.js";
import { onMounted, nextTick, reactive } from "vue";
import { ElTable, ElTableColumn, ElButton } from "element-plus";
import { useI18n } from "vue-i18n";
const { t } = useI18n()
const globalConfig = window.globalConfig
let state = reactive({
  tableHeight: 0,
  m_seriesID: "",
  m_fileList: [],
})
onMounted(() => {
  initwindowSize()
})
 
const downloadFile = (file_index, file_item) => {
  //
  let root = "";
  if (file_item.DsLocType == 1) {
    //oss域名
    let corpFlag = globalConfig.CorpInfo.CorpFlag; // 公司标识
    root = "https://spump.oss-cn-shanghai.aliyuncs.com/" + corpFlag + "/";
  } else if (file_item.DsLocType == 0) {
    //本地服务 服务器
    root = globalConfig.WebApiUrl.FileUrl + 'Data/';
  } else {
    root = globalConfig.WebApiUrl.FileUrl + 'Data/';
  }
  //
  let src = "";
  if (file_item.SourceType == 3) {
    let seriesDocumentUrl = "ProductDocument/";
    src = `${root}${seriesDocumentUrl}${file_item.DsFileName}`;
  } else if (file_item.SourceType == 9) {
    src = `${root}` + `${file_item.DsFileName}`;
  } else {
    //系列文件名
    let seriesFileUrl = "Series" + state.m_seriesID + "/";
    src = `${root}${seriesFileUrl}${file_item.DsFileName}`;
  }
 
  window.open(src, "_blank");
  //添加 附件下载日志
  initFileDownLog(file_item);
}
const initialFileList = (seriesID, fileList) => {
  state.m_seriesID = seriesID;
  if (fileList == null) fileList = [];
  state.m_fileList = fileList;
}
//添加 附件下载日志
const initFileDownLog = (file_item) => {
  //if(file_item.ID == 0)
  //  return ;
  let requestData = {
    SoftType: globalConfig.SoftType,
    Lang: file_item.Language,
    FileID: file_item.ID,
    SeriesID: state.m_seriesID,
    FileName: file_item.Name,
  };
 
  var action_name = "AddSeriesAttachLog";
  if (file_item.SourceType == 2) action_name = "AddBimFileLog";
 
  axiosHelper
    .post({
      version: 3,
      controller: "FileDownLog",
      action: action_name,
      data: requestData,
      apiUrlType: "main",
      isAddUrlSoftType: "false",
    })
    .then((res) => {
      // console.log(res);
    })
    .catch((err) => {
      // console.log(err);
    });
}
const initwindowSize = () => {
  nextTick(function () {
    let headerHeight = 0;
    let footerHeight = 0;
    if (document.querySelector("#app header")) {
      headerHeight = document.querySelector("#app header").clientHeight;
    }
    if (document.querySelector("#app footer")) {
      footerHeight = document.querySelector("#app footer").clientHeight;
    }
    state.tableHeight =
      document.body.clientHeight - headerHeight - footerHeight - 160; //
  });
  window.addEventListener(
    "resize",
    () => {
      return (() => {
        let headerHeight = 0;
        let footerHeight = 0;
        if (document.querySelector("#app header")) {
          headerHeight = document.querySelector("#app header").clientHeight;
        }
        if (document.querySelector("#app footer")) {
          footerHeight = document.querySelector("#app footer").clientHeight;
        }
        state.tableHeight =
          document.body.clientHeight - headerHeight - footerHeight - 160;
      })();
    },
    false
  );
}
 
defineExpose({ initialFileList })
</script>
<style>
.download-style {
  color: blue;
  text-decoration: underline;
  cursor: pointer;
}
</style>