ludc
2023-07-28 2badd826f8e96f1b9ed073133bdbb8c75ed02ff7
Source/UBCS-WEB/src/components/file/main.vue
@@ -65,15 +65,17 @@
import {mapGetters} from "vuex";
import {dateFormat} from "@/util/date";
import {validatenull} from "@/util/validate";
import func from "@/util/func";
export default {
  props: ["options","visible"],
  props: ["options","visible","ownbizOid"],
  data() {
    return {
      form: {},
      query: {},
      params:{},
      loading: false,
      hasPage:this.options.hasPage||false,
      page: {
        pageSize: 10,
        currentPage: 1,
@@ -86,10 +88,10 @@
      hasDel:validatenull(this.options.hasDel) ? true :this.options.hasDel,
      hasDownload:validatenull(this.options.hasDownload) ? true :this.options.hasDownload,
      option: {
        height:(this.options.tableHeight?this.options.tableHeight:'auto'),
        height:(this.options.tableHeight?this.options.tableHeight:'200'),
        calcHeight: 30,
        tip: false,
        searchShow: true,
        searchShow: false,
        searchMenuSpan: 6,
        border: true,
        index: true,
@@ -188,6 +190,7 @@
          prop: 'attachFile',
          type: 'upload',
          dragFile: true,
          showFileList:false,
          accept: this.options.uploadAccept || 'file',
          loadText: '文件上传中,请稍等',
          span: 24,
@@ -230,6 +233,12 @@
  },
  mounted() {
  },
  watch:{
    ownbizOid(val){
      this.setParams()
      this.refreshChange()
    }
  },
  methods: {
    setFormItem(){
@@ -311,9 +320,9 @@
    setParams() {
      var queryMap = {
        currentButtonKey: 'VIEW',
        ownbizOid:this.options.ownbizOid || "share",
        ownBtmName:this.options.ownbizBtm || "share",
        fileDocClassify: this.options.fileDocClassify|| "ADMIN_SHARE",
        ownbizOid: this.options.ownbizOid || "share",
        ownBtmName: this.options.ownbizBtm || "share",
        fileDocClassify: this.options.fileDocClassify || "ADMIN_SHARE",
        fileDocClassifyName: this.options.fileDocClassifyName || "管理员共享文件"
      };
      if (this.options.where) {
@@ -329,6 +338,12 @@
      }
      this.page.pageSize = this.options.pageObject.limit;
      this.page.currentPage = this.options.pageObject.page;
      this.attachOption.column[1].data.ownbizOid = this.options.ownbizOid || "share";
      this.attachOption.column[1].data.ownBtmName = this.options.ownbizBtm || "share";
      this.attachOption.column[1].data.fileDocClassify = this.options.fileDocClassify || "ADMIN_SHARE";
      this.attachOption.column[1].data.fileDocClassifyName = this.options.fileDocClassifyName || "管理员共享文件"
    },
    handleUpload() {
      this.attachOption.column[1].data.fileOid='';
@@ -353,29 +368,36 @@
      done();
    },
    uploadAfter(res, done, loading, column) {
      if(res.success){
        this.attachBox = false;
        this.$message.success('文件上传成功')
      }else{
        this.$message.error(res.msg);
      }
      this.attachBox = false;
      this.$message.success('文件上传成功')
      this.refreshChange();
      done();
    },
    uploadError(error, column) {
      this.$message.error('上传文件出现了异常')
      this.$message.error(error || '上传文件出现了异常')
    },
    handleDownload(row) {
      //window.open(`${row.link}`);
      let data=new FormData();
      if(row && row.oid){
        download(row.oid)
        data.append('fileOids',row.oid)
        this.downloadFile(data);
      }else{
        if (this.selectionList.length === 0) {
          this.$message.warning("请选择至少一条数据");
          return;
        }
        download(this.oids);
        data.append('fileOids',this.oids)
        this.downloadFile(data);
      }
    },
    downloadFile(data){
      download(data).then(res=>{
        // console.log(res);
        if(res){
          func.downloadFileByBlob(res);
        }
      });
    },
    rowDel(row) {
      this.$confirm("确定将选择文件删除?", {
@@ -384,7 +406,7 @@
        type: "warning"
      })
        .then(() => {
          return remove(row.oid);
          return remove([row.oid]);
        })
        .then(() => {
          this.onLoad(this.page);
@@ -405,7 +427,7 @@
        type: "warning"
      })
        .then(() => {
          return remove(this.oids);
          return remove(this.oids.split(','));
        })
        .then(() => {
          this.onLoad(this.page);
@@ -448,7 +470,7 @@
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
      this.onLoad(this.page);
    },
    onLoad(page, params={}) {
      this.loading = true;
@@ -461,7 +483,7 @@
      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;
        if(data && data.records.length>0 && this.options.fileDocClassifyCombox){
        if(this.options.fileDocClassifyCombox){
          this.data = data.records.map(item => {
            if(validatenull(item.fileDocClassifyName)&& !validatenull(item.fileDocClassify)){
              item.fileDocClassifyName = this.options.fileDocClassifyCombox[item.fileDocClassify] || '';
@@ -470,8 +492,10 @@
              ...item
            }
          })
        }else{
          this.data = data.records;
        }
        //this.data = data.records;
        this.loading = false;
        this.selectionClear();
      }).catch(error=>{