孔祥富
2021-03-10 06963d397d023ba076508808c8a0ec55da85067e
src/views/yunpan/zhishou.vue
@@ -81,14 +81,14 @@
            />提示:文件不要超过10个,单个文件大小不超过200M,单击或者拖动文件到下面区域,支持单个或批量文件的上传。</el-col>
          </el-row>
          <el-row style="background-color: rgba(0,0,0,0.2);">
            <el-col :span="17">
            <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="7">
            <el-col :span="10">
              <el-button
                type="primary"
                icon="el-icon-download"
@@ -104,9 +104,24 @@
              <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" width="20%">
          <el-form ref="updateFileName" :model="file" :rules="rules">
            <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"
@@ -151,7 +166,7 @@
                  >
                  <el-tooltip class="item" effect="dark" :content="node.filesname" placement="bottom">
                    <div style="padding-top: 14px;">
                      <el-checkbox v-model="checkedArr[index * rowCount + nodeIndex].isChecked" class="myRedCheckBox">{{ node.filesname }}</el-checkbox>
                      <el-checkbox v-model="checkedArr[index * 8 + nodeIndex].isChecked" class="myRedCheckBox">{{ node.filesname }}</el-checkbox>
                    </div>
                  </el-tooltip>
                </el-card>
@@ -191,6 +206,10 @@
export default {
  data() {
    return {
      updateFileNameFormVisible: false,
      file: {
        fileName: ''
      },
      rowCount: 12,
      mvrules: {
        folderid: [{ required: true, message: '请选择目录', trigger: 'change' }]
@@ -212,6 +231,10 @@
          { required: true, message: '请输入文件夹名称', trigger: 'blur' },
          { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' }
        ],
        fileName: [
          { required: true, message: '请输入文件名称', trigger: 'blur' },
          { min: 3, max: 10, message: '长度在 3 到 20 个字符', trigger: 'blur' }
        ],
        sort: [{ required: true, message: '请输入排序', type: 'number', trigger: 'blur' }]
      },
      formLabelWidth: '100px',
@@ -229,6 +252,51 @@
    this.initFolder()
  },
  methods: {
    updateFileName(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          var checke = ''
          this.checkedArr.forEach((v, i) => {
            if (v.isChecked) {
              checke = v.filesid
            }
          })
          // 生成查询文件的条件
          var params = { filesid: checke, filesname: this.file.fileName }
          this.$put('hr/filesUpload', { ...params }).then(() => {
            this.$message({
              message: '重命名成功!',
              type: 'success'
            })
            this.updateFileNameFormVisible = false
            this.file.fileName = ''
            // 生成查询文件的条件
            var initFileParams = {
              folderid: this.activities[this.beforeIndex].id,
              filesname: this.fileName
            }
            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 initFolder() {
      await this.$get('hr/folder').then(r => {
        this.activities = []