yz_08
2021-05-09 7227a8c87e9ca513a9d3bd9e3f0aa6daf21e92cb
src/views/yunpan/uploadfj.vue
@@ -1,5 +1,5 @@
<template>
  <div class="zs-main">
  <div class="zs-main fj-upload">
    <el-row class="search-title">
      <el-col :span="18" class="title">
        <div class="zs-title">上传附件</div>
@@ -12,15 +12,15 @@
          clearable
          placeholder="请输入文件名"
          show-word-limit
          style="width:200px"
          style="width:280px;margin-right: 10px"
        />
        <el-button type="primary" @click="findFileByFileName()">查询</el-button>
      </el-col>
    </el-row>
    <el-container style="background-color: #fff;">
      <el-aside width="210px" style="background-color: #fff;text-align: center;">
        <h4>{{ rowitem.empName }}:{{ rowitem.deptName }}</h4>
        <el-timeline>
      <el-aside width="210px" style="background-color: #fff;padding: 0 24px;text-align: center;height: 88vh;overflow: auto">
        <span style="font-size: 18px;font-weight: 700;">{{ rowitem.empName }}:{{ rowitem.deptName }}</span>
        <el-timeline style="margin-top: 10px">
          <el-timeline-item
            v-for="(activity, index) in activities"
            :key="index"
@@ -32,19 +32,19 @@
          >
            <span
              style="position: relative; top: -5px;"
              @click="clickTimeline(index, activity.id)"
              @click="clickTimeline(index)"
            >
              {{ activity.timestamp }}</span>
          </el-timeline-item>
        </el-timeline>
      </el-aside>
      <el-container>
      <el-container style="height: 88vh;">
        <el-header class="text-header">
          <el-row><el-col :span="24">
            <i
              class="el-icon-bell"
              style=" color: #a32c30; margin-right: 10px;"
            />提示:文件不要超过10个,单个文件大小不超过50M,单击或者拖动文件到下面区域,支持单个或批量文件的上传。</el-col>
              style="color: #a32c30; margin-right: 10px;"
            />提示:文件不要超过10个,单个文件大小不超过100M,单击或者拖动文件到下面区域,支持单个或批量文件的上传。</el-col>
          </el-row>
          <el-row style="background-color: rgba(0,0,0,0.2);">
            <el-col :span="16">
@@ -63,16 +63,30 @@
              >下载</el-button>
              <el-button
                type="primary"
                class="pri-del-btn"
                icon="el-icon-search"
                size="mini"
                @click="delFile()"
              >删除</el-button>
              <el-popconfirm title="是否移动附件?" @onConfirm="mvdialogFormVisible = true">
                <el-button slot="reference" class="hr-but" type="danger">移动</el-button>
                <el-button slot="reference" type="danger">转存</el-button>
              </el-popconfirm>
              <el-button type="warning" @click="openUpdateFileName()">重命名</el-button>
            </el-col>
          </el-row>
        </el-header>
        <el-dialog title="修改文件名" :visible.sync="updateFileNameFormVisible" append-to-body width="20%">
          <el-form ref="updateFileName" :model="file" :rules="mvrules">
            <el-form-item label="文件名" :label-width="formLabelWidth" prop="fileName">
              <el-input v-model="file.fileName" autocomplete="off" />
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="updateFileNameFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="updateFileName('updateFileName')">确 定</el-button>
          </div>
        </el-dialog>
        <el-dialog
          title="移动文件"
          :visible.sync="mvdialogFormVisible"
@@ -107,18 +121,35 @@
        <el-main style="background-color: #fff;">
          <el-row v-for="(data, index) in filesUploadData" :key="index">
            <template v-for="(node, nodeIndex) in data.node">
              <el-col v-if="node.isUpload === false" :key="node.filesid" :span="3">
              <el-col v-if="node.isUpload === false" :key="node.accessoryid" :span="3">
                <el-card
                  shadow="never"
                  @click.native="clickCard(index * 8 + nodeIndex)"
                >
                  <img
                  <el-image
                    v-if="'tif,bmp,jpg,png,gif'.indexOf(node.filesformat) == -1"
                    :src="showFileImg(node.filesformat)"
                    class="uploading-image"
                  >
                  <el-tooltip class="item" effect="dark" :content="node.filesname" placement="bottom">
                    <div style="padding-top: 14px;">
                    :preview-src-list="srcList"
                    @click="clickImg(node)"
                  />
                  <el-tooltip v-if="'tif,bmp,jpg,png,gif'.indexOf(node.filesformat) == -1" class="item" effect="dark" :content="node.filesname" placement="bottom">
                    <div style="padding-top: 14px;text-align: center">
                      <el-checkbox v-model="checkedArr[index * 8 + nodeIndex].isChecked" class="myRedCheckBox">{{ node.filesname }}</el-checkbox>
                    </div>
                  </el-tooltip>
                  <el-tooltip v-if="'tif,bmp,jpg,png,gif'.indexOf(node.filesformat) != -1" class="item" effect="dark" :content="node.filesname" placement="bottom">
                    <div style="padding-top: 14px;">
                      <el-image
                        style="width: 100px; height: 80px;margin-top: -10px;"
                        :src="getImg+node.accessoryid"
                        :preview-src-list="srcList"
                        @click="clickImg(node)"
                      />
                      <br>
                      <el-checkbox v-model="checkedArr[index * 8 + nodeIndex].isChecked" class="myRedCheckBox">
                        {{ node.filesname }}
                      </el-checkbox>
                    </div>
                  </el-tooltip>
                </el-card>
@@ -153,18 +184,33 @@
<script>
import { getToken } from '@/utils/auth'
import { pages } from '@/settings'
import { Loading } from 'element-ui'
export default {
  props: {
    rowitem: {
      type: Object,
      required: true
    },
    tableindex: {
      type: Number,
      required: true
    }
  },
  data() {
    return {
      srcList: [],
      getImg: pages.getAccessoryImage,
      updateFileNameFormVisible: false,
      file: {
        fileName: ''
      },
      mvrules: {
        labelid: [{ required: true, message: '请选择标签', trigger: 'change' }]
        labelid: [{ required: true, message: '请选择标签', trigger: 'change' }],
        fileName: [
          { required: true, message: '请输入文件名称', trigger: 'blur' },
          { min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur' }
        ]
      },
      mvdialogFormVisible: false,
      uploadSinglePath: pages.uploadSinglePath,
@@ -188,8 +234,63 @@
  },
  mounted() {
    this.initlabel()
    setTimeout(() => {
      this.clickTimeline(this.tableindex)
    }, 1500)
  },
  methods: {
    clickImg(node) {
      this.srcList = []
      if ('tif,bmp,jpg,png,gif'.indexOf(node.filesformat) >= 0) {
        this.srcList.push(this.getImg + node.accessoryid)
      }
    },
    updateFileName(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          var checke = ''
          this.checkedArr.forEach((v, i) => {
            if (v.isChecked) {
              checke = v.accessoryid
            }
          })
          // 生成查询文件的条件
          var params = { accessoryid: checke, filesname: this.file.fileName }
          this.$put('hr/empAccessory', { ...params }).then(() => {
            this.$message({
              message: '重命名成功!',
              type: 'success'
            })
            this.file.fileName = ''
            this.updateFileNameFormVisible = false
            // 生成查询文件的条件
            var initFileParams = {
              labelid: this.activities[this.beforeIndex].id,
              filesname: this.fileName,
              empid: this.rowitem.empId
            }
            this.initFile(initFileParams)
          })
        }
      })
    },
    openUpdateFileName() {
      var checke = []
      this.checkedArr.forEach((v, i) => {
        if (v.isChecked) {
          checke.push(v.filesid)
        }
      })
      if (checke.length <= 0) {
        this.$message({
          message: '请选择一个需要重命名的文件!',
          type: 'warning'
        })
      } else {
        this.updateFileNameFormVisible = true
      }
    },
    async initlabel() {
      await this.$get('hr/label').then(r => {
        this.activities = []
@@ -249,7 +350,7 @@
        }
      })
    },
    clickTimeline(index, id) {
    clickTimeline(index) {
      // 不这样操作的不会响应式更新
      // 赋值到新的列表
      var list = this.activities
@@ -292,6 +393,10 @@
    },
    showFileImg(type) {
      switch (type) {
        case 'xls':
          return require('../../assets/uploading/xls.png')
        case 'xlsx':
          return require('../../assets/uploading/xls.png')
        case 'txt':
          return require('../../assets/uploading/txt.png')
        case 'apk':
@@ -334,15 +439,23 @@
          return require('../../assets/uploading/jpg.png')
        case 'png':
          return require('../../assets/uploading/png.png')
        case 'doc':
          return require('../../assets/uploading/doc.png')
        case 'docx':
          return require('../../assets/uploading/docx.png')
        case 'tif':
          return require('../../assets/uploading/tif.png')
        case 'wps':
          return require('../../assets/uploading/wps.png')
        default:
          return require('../../assets/uploading/unknown.png')
      }
    },
    beforeAvatarUpload(file) {
      this.fileDate.labelid = this.activities[this.beforeIndex].id
      const isLt50M = file.size / 1024 / 1024 < 50
      const isLt50M = file.size / 1024 / 1024 < 100
      if (!isLt50M) {
        this.$message.error('上传文件不能超过 50MB!')
        this.$message.error('上传文件不能超过 100MB!')
      }
      return isLt50M
    },
@@ -394,9 +507,11 @@
          type: 'warning'
        })
      } else {
        const loadingInstance = Loading.service({ fullscreen: true })
        // 生成查询文件的条件
        var params = { accessoryids: checke.join(',') }
        this.$download('hr/empAccessory/download', { ...params }, this.activities[this.beforeIndex].timestamp + '.zip').then(() => {
          loadingInstance.close()
          this.$message({
            message: '下载成功!',
            type: 'success'
@@ -522,8 +637,8 @@
      }
   }
   .add-folder-but {
      background: #fff !important;
      color: #a32c30 !important;
      background: #a32c30 !important;
      color: #fff !important;
      margin-bottom: 20px;
   }
   padding: 0 15px 0 15px;
@@ -531,12 +646,15 @@
      line-height: 60px;
   }
   .uploading-image {
      width: 100%;
      height: 100%;
      width: 45%;
      height: 45%;
      display: block;
    margin: 0 auto;
   }
}
.fj-upload .el-timeline-item {
  padding-bottom: 1px;
}
.el-timeline-item__timestamp {
   font-size: 15px;
   color: #000;
@@ -567,6 +685,14 @@
/* 设置鼠标经过对勾框,对勾框边框的颜色 */
.myRedCheckBox .el-checkbox__inner:hover {
   border-color: #a32c30;
}
.myRedCheckBox .el-checkbox__label {
  overflow: hidden;
  text-overflow:ellipsis;
  white-space: nowrap;
}
.myRedCheckBox .el-checkbox__input {
  vertical-align: text-top;
}
.avatar-uploader .el-upload {
@@ -600,6 +726,11 @@
   width: 100px;
   height: 100px;
}
.el-image .el-image-viewer__mask {
  background-color: #fff !important;
  opacity: 1;
}
</style>
<style lang="scss" scoped>
.el-main {
@@ -624,4 +755,9 @@
.el-input-number {
   width: 100%;
}
.pri-del-btn {
  background-color: rgb(64, 158, 255);
  border-color: rgb(64, 158, 255);
}
</style>