ludc
2023-07-27 efff5c8410c9657915eb05615c13c2de7421c61a
修改文件下载不成功问题
已修改9个文件
108 ■■■■■ 文件已修改
Source/UBCS-WEB/src/api/GetItem.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/api/resource/file.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/Master/MasterTransfer.vue 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/code-dialog-page/formulaEditor.vue 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/file/main.vue 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/store/modules/user.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/views/code/code.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/views/system/menu.vue 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS/ubcs-ops-api/ubcs-resource-api/src/main/java/com/vci/ubcs/resource/utils/FileDownloadUtil.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/api/GetItem.js
@@ -61,13 +61,7 @@
  return request({
    url: 'api/ubcs-code/mdmEngineController/exportCode',
    method: 'excel',
    responseType: 'json', // 设置响应类型为arraybuffer
    headers: {
      'Content-Type': 'application/vnd.ms-excel', // 设置请求头为二进制流类型
      // 在这里可以设置其他请求头信息
      // 例如:
      // 'Authorization': 'Bearer your-token',
    },
    responseType: 'blob', // 设置响应类型为blob
    params:{
      ...data
    }
Source/UBCS-WEB/src/api/resource/file.js
@@ -41,6 +41,7 @@
    url: '/api/ubcs-resource/fileController/downloadFilesByOids',
    method: 'post',
    headers:{'Content-Type':'application/x-www-form-urlencoded;charset=UTF-8'},
    responseType: 'blob',
    data: data
  })
Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
@@ -134,30 +134,21 @@
          exportCode({codeClassifyOid:this.codeClassifyOid,'conditionMap[oid]':ids,...exportArr}).then(res=>{
            console.log('res',res)
            const filename = '下载.xlsx'; // 下载的文件名
            const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
            const a = document.createElement('a');
            const url = window.URL.createObjectURL(blob);
            a.href = url;
            a.download = filename;
            a.style.display = 'none';
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            window.URL.revokeObjectURL(url);
            // const filename = '下载.xlsx'; // 下载的文件名
            // const blob = new Blob([response.data], { type: 'application/vnd.ms-excel' });
            //
            // const url = window.URL.createObjectURL(blob);
            // const link = document.createElement('a');
            // link.href = url;
            // link.setAttribute('download', filename);
            // document.body.appendChild(link);
            // link.click();
            // document.body.removeChild(link);
            // URL.revokeObjectURL(url);
            let blob = new Blob([res.data], {
              type: res.data.type + ";charset=utf-8",
            });
            let src = window.URL.createObjectURL(blob);
            if (src) {
              let link = document.createElement("a");
              link.style.display = "none";
              link.href = src;
              link.setAttribute("download", "文件名字.xls");
              document.body.appendChild(link);
              link.click();
              document.body.removeChild(link); //下载完成移除元素
              window.URL.revokeObjectURL(src); //释放掉blob对象
            }
          })
        }
      };
    },
Source/UBCS-WEB/src/components/code-dialog-page/formulaEditor.vue
@@ -649,13 +649,14 @@
    };
  },
  watch: {
      // 监听父组件传的窗口显示隐藏的值
      visible (){
          this.isShowformulaEdit = this.visible;
      }
      // 监听父组件传的窗口显示隐藏的值,以及值的回填
      visible() {
        this.isShowformulaEdit = this.visible;
        this.formulaContent=this.componentRuleText || '';
      },
  },
  mounted() {
    this.formulaContent=this.componentRuleText
  },
  methods: {
Source/UBCS-WEB/src/components/file/main.vue
@@ -65,6 +65,7 @@
import {mapGetters} from "vuex";
import {dateFormat} from "@/util/date";
import {validatenull} from "@/util/validate";
import func from "@/util/func";
export default {
  props: ["options","visible","ownbizOid"],
@@ -380,16 +381,41 @@
      let data=new FormData();
      if(row && row.oid){
        data.append('fileOids',row.oid)
        download(data)
        this.downloadFile(data);
      }else{
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        data.append('fileOids',this.oids)
        download(data);
        this.downloadFile(data);
      }
    },
    downloadFile(data){
      download(data).then(res=>{
        // console.log(res);
        if(res){
          const fileNames = res.headers['content-disposition'].split(";");
          let characterSet = fileNames[2].split("filename*=")[1];
          let fileName = decodeURI(fileNames[1].split("filename=")[1],characterSet);
          // console.log(fileName)
          let blob = new Blob([res.data], {
            type: res.data.type + ";charset=utf-8",
          });
          let src = window.URL.createObjectURL(blob);
          if (src) {
            let link = document.createElement("a");
            link.style.display = "none";
            link.href = src;
            link.setAttribute("download", fileName);
            document.body.appendChild(link);
            link.click();
            document.body.removeChild(link); //下载完成移除元素
            window.URL.revokeObjectURL(src); //释放掉blob对象
          }
        }
      });
    },
    rowDel(row) {
      this.$confirm("确定将选择文件删除?", {
        confirmButtonText: "确定",
Source/UBCS-WEB/src/store/modules/user.js
@@ -224,6 +224,7 @@
      return new Promise((resolve) => {
        getButtons().then(res => {
          const data = res.data.data;
          // console.log(data);
          commit('SET_PERMISSION', data);
          resolve();
        })
Source/UBCS-WEB/src/views/code/code.vue
@@ -767,6 +767,7 @@
        <formula-editor
          ref="formulaEditor"
          @updateFormulaContent="updateFormulaContent"
          :componentRuleText="form.getValueClass"
          :visible.sync="formulaEditorParams.formulaEditorSettingBox"
          :thisSceneTableData="formulaEditorParams.thisSceneTableData"
          :systemVariableTableData="formulaEditorParams.systemVariableTableData">
@@ -2571,7 +2572,6 @@
            this.loadlistClassifyLinkAttr();
          }else if(condition === 'value'){
            //打开公式编辑框,第二层嵌套对话框
            //this.$refs.formulaEditor.isShowformulaEdit = true;
            this.formulaEditorParams.formulaEditorSettingBox = true;
          }else if(condition === 'parentClassifySecOid'){
            this.parentClsfyParams.isShowParentClassifySettingBox = true;
@@ -2768,7 +2768,7 @@
          if(enumCach == null) {
            getDictionary("codeFillSeparator").then(res=>{
              this.enumParam.codeFillSeparator = res.data.data;
              localStorage.setItem(key,JSON.stringify(res.data.data));
              localStorage.setItem("codeFillSeparator",JSON.stringify(res.data.data));
            })
          }
        },
Source/UBCS-WEB/src/views/system/menu.vue
@@ -34,6 +34,12 @@
          plain
          @click="cloneMenuButton">从其他菜单克隆按钮
        </el-button>
        <el-button type="info"
          size="small"
          icon="el-icon-connection"
          plain
          @click="test">test
        </el-button>
      </template>
      <template slot-scope="scope" slot="menu">
        <el-button
@@ -431,6 +437,7 @@
      },
    },
    computed: {
      // mapGetters: 辅助函数仅仅将store 中的 getter 映射到局部计算属性
      ...mapGetters(["userInfo", "permission"]),
      permissionList() {
        return {
@@ -439,6 +446,7 @@
          delBtn: this.vaildData(this.permission.menu_delete, false),
          editBtn: this.vaildData(this.permission.menu_edit, false)
        };
      },
      ids() {
        let ids = [];
@@ -450,6 +458,10 @@
    },
    methods: {
      test(){
        console.log(this.permission)
      },
      /** 从其他菜单克隆按钮 */
      cloneMenuButton(){
        if(this.selectionList.length != 1 || this.selectionList[0].category === 2){
Source/UBCS/ubcs-ops-api/ubcs-resource-api/src/main/java/com/vci/ubcs/resource/utils/FileDownloadUtil.java
@@ -41,10 +41,10 @@
    public static void downloadFile(HttpServletResponse response, FileObjectBO fileObjectBO,boolean closeInputStream) throws IOException {
        MediaType mediaType = MediaTypeFactory.getMediaType(fileObjectBO.getBucketName() + "." + fileObjectBO.getFileExtension()).orElse(MediaType.APPLICATION_OCTET_STREAM);
        // 设置强制下载不打开
        response.setContentType(mediaType.toString());
        response.setContentType(mediaType.toString()+";application/force-download;charset=UTF-8");
        try{
            String fileName = URLEncoder.encode(fileObjectBO.getName() + "." + fileObjectBO.getFileExtension(), "UTF8");
            response.addHeader("Content-Disposition", "attachment; filename="+ fileName+ ";filename*=utf-8''" + fileName);
            response.addHeader("Content-Disposition", "attachment;filename="+ fileName+ ";filename*=utf-8''");
        }catch(Exception e){
            if(log.isErrorEnabled()){
                log.error("设置文件的名称到响应流的时候出错",e);