wangting
2023-06-16 ea81762709db76159f8c0cdb7841b067be5857d5
文件列表展示
已修改2个文件
已添加4个文件
576 ■■■■■ 文件已修改
Source/UBCS-WEB/src/api/resource/file.js 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/file/inDialog.vue 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/file/inHtml.vue 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/file/main.vue 325 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/refer/vciWebReferDefalut.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue 110 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/api/resource/file.js
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,74 @@
import request from '@/router/axios';
export const getList = (page, limit, params) => {
  return request({
    url: '/api/ubcs-resource/fileController/listFiles',
    method: 'get',
    params: {
      ...params,
      page,
      limit
    }
  })
}
export const remove = (oids) => {
  return request({
    url: '/api/ubcs-resource/fileController/deleteFile',
    method: 'post',
    params: {
      oids
    }
  })
}
export const upload = (row) => {
  return request({
    url: '/api/ubcs-resource/fileController/uploadFile',
    method: 'post',
    data: row
  })
}
export const update = (row) => {
  return request({
    url: '/api/ubcs-resource/fileController/uploadFile',
    method: 'post',
    data: row
  })
}
export const download = (oids) => {
  return request({
    url: '/api/ubcs-resource/fileController/downloadFilesByOids',
    method: 'get',
    params: {
      oids
    }
  })
}
/**
 * ä½¿ç”¨æ–‡ä»¶ä¸»é”®èŽ·å–å¯¹è±¡
 * @param oid ä¸»é”®
 * @return æ–‡ä»¶æ˜¾ç¤ºå¯¹è±¡
 */
export const getFile = (oid) => {
  return request({
    url: '/api/ubcs-resource/fileController/get',
    method: 'get',
    params: {
      oid
    }
  })
}
export const listFilesByOids = (oids) => {
  return request({
    url: '/api/ubcs-resource/fileController/listFilesByOids',
    method: 'get',
    params: {
      oids
    }
  })
}
Source/UBCS-WEB/src/components/file/inDialog.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,40 @@
<template>
  <div>
  <el-dialog :title="options.title|| '附件管理'"
             :visible.sync="visible"
             append-to-body
             class="avue-dialog avue-dialog--top"
             @close="close"
             top="0"
             :width="options.width|| '80%'">
    <fileContent
      :options="options"
    ></fileContent>
  </el-dialog>
  </div>
</template>
<script>
import fileContent from './main.vue';
export default {
  name: "inDialog",
  components: { fileContent },
  props: ["options","visible"],
  data(){
    return{
    }
  },
  computed: {
  },
  methods:{
    close(){
      this.$emit("close", false);
    }
  }
}
</script>
<style scoped>
</style>
Source/UBCS-WEB/src/components/file/inHtml.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,26 @@
<template>
  <basic-container>
    <fileContent
      :options="options"
    ></fileContent>
  </basic-container>
</template>
<script>
import fileContent from './main.vue';
export default {
  name: "inHtml",
  components: { fileContent },
  props: ["options"],
  data(){
    return{
    }
  },
  computed: {
  }
}
</script>
<style scoped>
</style>
Source/UBCS-WEB/src/components/file/main.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,325 @@
<template>
  <basic-container>
    <avue-crud :option="option"
               :table-loading="loading"
               :data="data"
               :page.sync="page"
               :permission="permissionList"
               :before-open="beforeOpen"
               v-model="form"
               ref="crud"
               @row-del="rowDel"
               @search-change="searchChange"
               @search-reset="searchReset"
               @selection-change="selectionChange"
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="refreshChange"
               @on-load="onLoad">
      <template slot="menuLeft">
        <el-button type="primary"
                   size="small"
                   plain
                   icon="el-icon-upload2"
                   @click="handleUpload">上 ä¼ 
        </el-button>
        <el-button type="primary"
                   size="small"
                   plain
                   icon="el-icon-edit"
                   @click="handleEdit">ä¿® æ”¹
        </el-button>
        <el-button type="danger"
                   size="small"
                   icon="el-icon-delete"
                   plain
                   @click="handleDelete">删 é™¤
        </el-button>
      </template>
      <template slot-scope="scope" slot="menu">
        <el-button type="text"
                   icon="el-icon-download"
                   size="small"
                   @click="handleDownload(scope.row)">下载
        </el-button>
      </template>
    </avue-crud>
    <el-dialog title="上传附件列表"
               append-to-body
               :visible.sync="attachBox"
               width="555px">
      <avue-form ref="form" :option="attachOption" v-model="attachForm" :upload-before="uploadBefore" :upload-after="uploadAfter" :upload-error="uploadError">
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
<script>
import {getList, getFile,upload,update, remove,download} from "@/api/resource/file";
import {mapGetters} from "vuex";
import {dateFormat} from "@/util/date";
export default {
  props: ["options","visible"],
  data() {
    return {
      form: {},
      query: {},
      params:{},
      loading: false,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      attachBox: false,
      selectionList: [],
      option: {
        height: 'auto',
        calcHeight: 30,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true,
        index: true,
        viewBtn: true,
        selection: true,
        dialogClickModal: false,
        column: [
          {
            label: "文件名称",
            prop: "name",
            search: true,
            /*formatter:function(d){
              if(this.options.hasDownloadRight != false){
                //说明有下载文件的权限,那么我们就添加一个超链接
                return ''//'<a name="filenamedownloadlink " class="layui-btn layui-btn-intable" lay-event="PREVIEW" fileoid="' + d.oid +'">' + (d.id?d.id:d.name) + '</a>';
              }else{
                return d.id || d.name;
              }
            }*/
          },
          {
            label: "文件大小",
            prop: "fileSize",
            formatter:function(d){
              if(!d.fileSize || d.fileSize == null || d.fileSize*1 == 0 || isNaN(d.fileSize*1) ){
                return "未知大小";
              }else{
                //原始大小是B
                var filesize = d.fileSize*1;
                if(filesize>1024*1024*1024*1024){
                  return parseInt(filesize/(1024*1024*1024*1024)) + "TB";
                }else if(filesize> 1024*1024*1024){
                  return parseInt(filesize/(1024*1024*1024)) + "GB";
                }else if(filesize> 1024*1024){
                  return parseInt(filesize/(1024*1024)) + "MB";
                }else if(filesize> 1024){
                  return parseInt(filesize/1024) + "KB";
                }else {
                  return filesize + "B";
                }
              }
            }
          },
          /*{
            label: "密级",
            prop: "secretGradeText"
          },
          {
            label: "文档类别",
            prop: "fileDocClassifyName"
          },*/
          {
            label: "创建者",
            prop: "creator"
          },
          {
            label: "创建时间",
            prop: "createTime"
          },
        ]
      },
      data: [{
        btmname: "fileobject",
        createTime: "2023-06-14 16:08:50.002",
        creator: "1",
        fileDocClassify: "undefined",
        fileDocClassifyName: null,
        fileExtension: "png",
        filePath: "VolumnFactoryService:/f87a4c92-ce6e-458b-aad0-0c76bd5eeb35\\54120082-76aa-4092-abbf-b13cb40606c5",
        fileSize: 858,
        id: "assignRole",
        name: "assignRole",
        nameOid: "9FF4C05D-4EFA-F00B-0080-5ABB50257D4E",
        oid: "54120082-76aa-4092-abbf-b13cb40606c5",
        ownBtmname: "wupin",
        ownbizOid: "6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9",
        owner: "1",
        secretGrade: null,
        secretGradeText: null
      }],
      attachForm: {},
      attachOption: {
        submitBtn: true,
        emptyBtn: true,
        column: [
          {
            label: '附件上传',
            prop: 'attachFile',
            type: 'upload',
            dragFile: true,
            loadText: '文件上传中,请稍等',
            span: 24,
            propsHttp: {
              res: 'data'
            },
            action: "/api/ubcs-resource/fileController/uploadFile"
          }
        ]
      }
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: false,
        editBtn: false,
        viewBtn: false,
        delBtn: this.vaildData(this.permission.attach_delete, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    }
  },
  methods: {
    setParams(){
      var params={
        ownbizOid:options.ownbizOid || '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9',
        ownbizBtm:options.ownbizBtm || 'wupin',
        fileDocClassify:options.fileDocClassify || '!=processAuditSuggest'
      }
      this.params=params;
    },
    handleUpload() {
      this.attachBox = true;
    },
    handleEdit() {
      this.attachBox = true;
    },
    uploadBefore(file, done, loading,column) {
      console.log(file,column)
      //如果你想修改file文件,由于上传的file是只读文件,必须复制新的file才可以修改名字,完后赋值到done函数里,如果不修改的话直接写done()即可
      var newFile = new File([file], '1234', { type: file.type });
      done(newFile)
      this.$message.success('上传前的方法')
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(column);
      this.attachBox = false;
      this.refreshChange();
      done();
    },
    uploadError(error, column) {
      this.$message.success('上传失败回调')
      console.log(error, column)
    },
    handleDownload(row) {
      window.open(`${row.link}`);
    },
    rowDel(row) {
      this.$confirm("确定将选择文件删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params) {
      //this.loading = true;
      params=this.params || {}
      /*getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });*/
    }
  }
};
</script>
<style>
</style>
Source/UBCS-WEB/src/components/refer/vciWebReferDefalut.vue
@@ -180,6 +180,7 @@
              ...item,
              label: item.title,
              prop: item.field,
              formatter:item.template,
              search: true
            }
          }
Source/UBCS-WEB/src/views/MasterData/FormTempalteTest.vue
@@ -1,50 +1,60 @@
<template>
  <div>
    <el-button @click="visible = true">测试</el-button>
    <el-button @click="visible1 = true">相似项查询</el-button>
    <FormTemplateDialog
      :visible.sync="visible"
      :type="this.type"
      :templateOid="this.templateOid"
      :codeClassifyOid="this.codeClassifyOid"
      :codeRuleOid="this.codeRuleOid"
      :disabledProp="disabledProp"
      :rowOid="rowOid"
      @submit="submit"
    ></FormTemplateDialog>
    <ResembleQueryDialog
      :visible.sync="visible1"
      :type="this.type"
      :templateOid="this.templateOid"
      :codeClassifyOid="this.codeClassifyOid"
      :codeRuleOid="this.codeRuleOid"
    ></ResembleQueryDialog>
  </div>
</template>
<script>
import ResembleQueryDialog from '@/components/FormTemplate/ResembleQueryDialog.vue';
export default {
  name: "FormTempalteTest",
  components: { ResembleQueryDialog },
  data() {
    return {
      visible: false,
      visible1: false,
      // é»˜è®¤ç¦ç”¨çš„表元素
      disabledProp: ["id", 'lcstatus'],
      // è¡¨å•类型
      type: "add",
      templateOid: "A12826E4-2B66-6D56-DE30-92BB1D7F607F",
      codeClassifyOid: "D9CF223F-317D-71EB-BD11-433A94CAD9F3",
      codeRuleOid: "B95872A6-9CEA-D490-8F1B-9D26548CAF96",
      rowOid: '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9'
    };
  },
  methods: {
    submit(data) {
      console.log(data);
    }
  }
};
</script>
<template>
  <div>
    <el-button @click="visible = true">测试</el-button>
    <el-button @click="visible1 = true">相似项查询</el-button>
    <el-button @click="visible2 = true">附件管理dialog</el-button>
    <FormTemplateDialog
      :visible.sync="visible"
      :type="this.type"
      :templateOid="this.templateOid"
      :codeClassifyOid="this.codeClassifyOid"
      :codeRuleOid="this.codeRuleOid"
      :disabledProp="disabledProp"
      :rowOid="rowOid"
      @submit="submit"
    ></FormTemplateDialog>
    <ResembleQueryDialog
      :visible.sync="visible1"
      :type="this.type"
      :templateOid="this.templateOid"
      :codeClassifyOid="this.codeClassifyOid"
      :codeRuleOid="this.codeRuleOid"
    ></ResembleQueryDialog>
    <fileInHtml :options="{}"></fileInHtml>
    <fileinDialog
      :visible="visible2"
      :options="{}"
      @close="visible2=false"
    ></fileinDialog>
  </div>
</template>
<script>
import ResembleQueryDialog from '@/components/FormTemplate/ResembleQueryDialog.vue';
import fileInHtml from '@/components/file/inHtml.vue';
import fileinDialog from '@/components/file/inDialog.vue';
export default {
  name: "FormTempalteTest",
  components: { ResembleQueryDialog ,fileInHtml ,fileinDialog},
  data() {
    return {
      visible: false,
      visible1: false,
      visible2: false,
      // é»˜è®¤ç¦ç”¨çš„表元素
      disabledProp: ["id", 'lcstatus'],
      // è¡¨å•类型
      type: "add",
      templateOid: "78B8C7C5-A042-0B96-FE6D-65421451782A",
      codeClassifyOid: "4524E801-6CC6-92E8-1AC3-2AB9604E8F96",
      codeRuleOid: "B95872A6-9CEA-D490-8F1B-9D26548CAF96",
      rowOid: '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9'
    };
  },
  methods: {
    submit(data) {
      console.log(data);
    }
  }
};
</script>