孔祥富
2021-03-10 06963d397d023ba076508808c8a0ec55da85067e
src/views/yunpan/uploadfj.vue
@@ -47,14 +47,14 @@
            />提示:文件不要超过10个,单个文件大小不超过50M,单击或者拖动文件到下面区域,支持单个或批量文件的上传。</el-col>
          </el-row>
          <el-row style="background-color: rgba(0,0,0,0.2);">
            <el-col :span="16">
            <el-col :span="14">
              <el-checkbox
                v-model="checkAll"
                class="myRedCheckBox"
                style="color: #000; margin-left: 20px;"
                @change="checkAllMethods()"
              >全选</el-checkbox></el-col>
            <el-col :span="8">
            <el-col :span="10">
              <el-button
                type="primary"
                icon="el-icon-download"
@@ -70,9 +70,23 @@
              <el-popconfirm title="是否移动附件?" @onConfirm="mvdialogFormVisible = true">
                <el-button slot="reference" class="hr-but" type="danger">转存</el-button>
              </el-popconfirm>
              <el-button type="warning" @click="openUpdateFileName()">重命名</el-button>
              <el-button type="primary" @click="downloaddialogFormVisible = true">查看</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"
@@ -110,11 +124,11 @@
              <el-col v-if="node.isUpload === false" :key="node.filesid" :span="3">
                <el-card
                  shadow="never"
                  @click.native="clickCard(index * 8 + nodeIndex)"
                >
                  <img
                    :src="showFileImg(node.filesformat)"
                    class="uploading-image"
                    @click="clickCard(index * 8 + nodeIndex)"
                  >
                  <el-tooltip class="item" effect="dark" :content="node.filesname" placement="bottom">
                    <div style="padding-top: 14px;">
@@ -164,8 +178,16 @@
  },
  data() {
    return {
      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: 10, message: '长度在 3 到 20 个字符', trigger: 'blur' }
        ]
      },
      mvdialogFormVisible: false,
      uploadSinglePath: pages.uploadSinglePath,
@@ -191,6 +213,53 @@
    this.initlabel()
  },
  methods: {
    updateFileName(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          var checke = ''
          debugger
          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 = []