wangting
2023-06-19 771cff371aa3ea6352e639d4636190a5fd237d33
附件列表展示、上传修改下载删除
已修改3个文件
240 ■■■■ 文件已修改
Source/UBCS-WEB/src/api/resource/file.js 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/file/inDialog.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/components/file/main.vue 224 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Source/UBCS-WEB/src/api/resource/file.js
@@ -15,35 +15,35 @@
export const remove = (oids) => {
  return request({
    url: '/api/ubcs-resource/fileController/deleteFile',
    method: 'post',
    method: 'delete',
    params: {
      oids
    }
  })
}
export const upload = (row) => {
export const upload = (file) => {
  return request({
    url: '/api/ubcs-resource/fileController/uploadFile',
    method: 'post',
    data: row
    data: file
  })
}
export const update = (row) => {
export const update = (file) => {
  return request({
    url: '/api/ubcs-resource/fileController/uploadFile',
    method: 'post',
    data: row
    data: file
  })
}
export const download = (oids) => {
export const download = (fileOids) => {
  return request({
    url: '/api/ubcs-resource/fileController/downloadFilesByOids',
    method: 'get',
    params: {
      oids
      fileOids
    }
  })
}
Source/UBCS-WEB/src/components/file/inDialog.vue
@@ -1,6 +1,6 @@
<template>
  <div>
  <el-dialog :title="options.title|| '附件管理'"
  <el-dialog :title="options.title|| '附件列表'"
             :visible.sync="visible"
             append-to-body
             class="avue-dialog avue-dialog--top"
Source/UBCS-WEB/src/components/file/main.vue
@@ -44,11 +44,11 @@
        </el-button>
      </template>
    </avue-crud>
    <el-dialog title="上传附件列表"
    <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 ref="form" :option="attachOption" v-model="attachForm" :upload-before="uploadBefore"  :upload-after="uploadAfter" :upload-error="uploadError">
      </avue-form>
    </el-dialog>
  </basic-container>
@@ -140,6 +140,16 @@
          },
        ]
      },
      columnType: {
        text: "input",
        combox: "select",
        truefalse: "switch",
        number: "number",
        textarea: "textarea",
        datetime: "datetime",
        date: "date",
        refer: "refer",
      },
      data: [{
        btmname: "fileobject",
        createTime: "2023-06-14 16:08:50.002",
@@ -161,21 +171,44 @@
      }],
      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"
          }
        submitBtn: false,
        emptyBtn: false,
        column: [{
          prop: 'fileDocClassify',
          label: '文件类型',
          props: {
            label: 'value',
            value: 'key'
          },
          change: () => {
            (!!this.options.fileDocClassifyCombox) && this.changeFun('fileDocClassify');
          },
          blur: () => {
            (!this.options.fileDocClassifyCombox) && this.changeFun('fileDocClassify');
          },
          value: this.options.fileDocClassify || "ADMIN_SHARE",
          type: (!this.options.fileDocClassifyCombox) ? 'input' : 'select',
          dicData: (this.options.fileDocClassifyCombox || []),//[{key: 'text', value: '文本框'}]
          display: (!!this.options.fileDocClassifyCombox)
        }, {
          label: '附件上传',
          prop: 'attachFile',
          type: 'upload',
          dragFile: true,
          accept: this.options.uploadAccept || 'file',
          loadText: '文件上传中,请稍等',
          span: 24,
          propsHttp: {
            res: 'data'
          },
          data: {
            ownbizOid:this.options.ownbizOid || "share",
            ownBtmname:this.options.ownbizBtm || "share",
            fileDocClassify:this.options.fileDocClassify || "ADMIN_SHARE",
            fileDocClassifyName:this.options.fileDocClassifyName || "管理员共享文件"
          },
          action: "/api/ubcs-resource/fileController/uploadFile"
        }
        ]
      }
    };
@@ -190,48 +223,144 @@
        delBtn: this.vaildData(this.permission.attach_delete, false)
      };
    },
    ids() {
      let ids = [];
    oids() {
      let oids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
        oids.push(ele.oid);
      });
      return ids.join(",");
      return oids.join(",");
    }
  },
  mounted() {
    this.setFormItem();
    this.setParams()
  },
  methods: {
    setParams(){
      var params={
        ownbizOid:options.ownbizOid || '6EF696C3-CD87-0E7C-1EA1-8DE3913A95C9',
        ownbizBtm:options.ownbizBtm || 'wupin',
        fileDocClassify:options.fileDocClassify || '!=processAuditSuggest'
    setFormItem(){
      /*this.options.formItems=[{
        field: 'fileDocClassify11',
        title: '文件类型',
        type:  'combox',
        data: [{key: 'text', value: '文本框'},{key: 'number', value: '数字框'}]
      }]*/
      if(this.options && this.options.formItems){
        this.options.formItems.forEach(item => {
          // 设置表单校验的规则,文本
          let message = "请选择";
          let trigger = "change";
          if (item.type === "text") {
            message = "请输入";
            trigger = "blur";
          }
          this.attachOption.column.push( {
            ...item,
            label: item.title,
            prop: item.field,
            display: !item.hidden,
            value: item.defaultValue,
            disabled: item.readOnly,
            type: this.columnType[item.type],
            dicData: this.getDataList(item.type, item.data),
            change: () => {
              if(item.type !== "text"  && item.type !== "number" && item.type !== "textarea"){
                this.changeFun(item.field);
              }
            },
            blur: () => {
              if(item.type == "text"  || item.type == "number" || item.type == "textarea"){
                this.changeFun(item.field);
              }
            },
            rules: [
              {
                required: item.required,
                message: `请${message}${item.title}`,
                trigger,
              },
              {
                // 如果没有正则则匹配任何字符
                pattern: item.verify ? item.verify : /[\s\S.]*/g,
                message: item.tooltips,
                trigger,
              },
            ],
            props: {
              label: 'value',
              value: 'key'
            }
          })
        })
      }
      this.params=params;
    },
    changeFun( prop) {
      this.attachOption.column[1].data[prop]=this.attachForm[prop]
    },
    getDataList(type, dicData) {
      if (type === "truefalse") {
        return [
          {
            key: false,
            value: "否",
          },
          {
            key: true,
            value: "是",
          },
        ];
      } else if (type === "combox") {
        return dicData;
      }
      return [];
    },
    setParams(){
      var queryMap = {
        currentButtonKey:'VIEW',
        ownbizOid:this.options.ownbizOid,
        ownbizBtm:this.options.ownbizBtm
      };
      if(this.options.where){
        Object.assign(queryMap,this.options.where);
      }
      this.params=queryMap;
    },
    handleUpload() {
      this.attachOption.column[1].data.fileOid='';
      delete this.attachOption.column[1].data.oid;
      delete this.attachOption.column[1].data.updateFileFlag;
      this.attachBox = true;
    },
    handleEdit() {
      if(this.selectionList.length==0){
        this.$message.error('请选择需要修改的文件')
        return false;
      }else if(this.selectionList.length>1){
        this.$message.error('请选择一条数据')
        return false;
      }
      this.attachOption.column[1].data.fileOid=this.oids;
      this.attachOption.column[1].data.oid=this.oids;
      this.attachOption.column[1].data.updateFileFlag=true
      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('上传前的方法')
      done();
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(column);
      this.attachBox = false;
      if(res.success){
        this.attachBox = false;
        this.$message.success('文件上传成功')
      }else{
        this.$message.error(res.msg);
      }
      this.refreshChange();
      done();
    },
    uploadError(error, column) {
      this.$message.success('上传失败回调')
      console.log(error, column)
      this.$message.error('上传文件出现了异常')
    },
    handleDownload(row) {
      window.open(`${row.link}`);
      //window.open(`${row.link}`);
      download(row.oid)
    },
    rowDel(row) {
      this.$confirm("确定将选择文件删除?", {
@@ -240,7 +369,7 @@
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
          return remove(row.oid);
        })
        .then(() => {
          this.onLoad(this.page);
@@ -261,7 +390,7 @@
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
          return remove(this.oids);
        })
        .then(() => {
          this.onLoad(this.page);
@@ -287,7 +416,7 @@
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      this.onLoad(this.page);
      done();
    },
    selectionChange(list) {
@@ -306,16 +435,21 @@
    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 => {
    onLoad(page, params={}) {
      this.loading = true;
      var query={}
      if (this.query) {
        for (var key in this.query) {
          query['conditionMap["' + key + '"]'] = this.query[key];
        }
      }
      getList(page.currentPage, page.pageSize, Object.assign(params,this.params, query,this.query)).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });*/
      });
    }
  }
};