Newer
Older
KaiFengPC / src / views / document / fileManagement / updateRecord / index.vue
@zhangdeliang zhangdeliang 1 day ago 4 KB update
<template>
  <div class="updateRecord">
    <div class="top">
      <el-form ref="ruleForm" inline :model="form">
        <el-form-item label="所属分类:" prop="typeId">
          <el-tree-select
            v-model="form.typeId"
            :data="treeData"
            node-key="id"
            :render-after-expand="false"
            :props="{ label: 'typeName' }"
            check-strictly
            clearable
            style="width: 100%"
            class="fileTreeSel"
          />
        </el-form-item>
        <el-form-item label="文件名称:" prop="fileName">
          <el-input v-model="form.fileName" placeholder="请输入文件名称" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="search"> 搜索</el-button>
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="tableData" v-loading="loading" stripe :max-height="600">
      <el-table-column type="index" width="55" label="序号" />
      <el-table-column label="文件名称" prop="fileName" show-overflow-tooltip width="200" />
      <el-table-column label="文件编号" prop="fileId" show-overflow-tooltip />
      <el-table-column label="创建时间" prop="createTime" show-overflow-tooltip />
      <el-table-column label="更新时间" prop="updateTime" show-overflow-tooltip />
      <el-table-column label="更新前大小" prop="beforeSize" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{
            row.beforeSize
              ? row.beforeSize > 1024
                ? (row.beforeSize / 1024 / 1024).toFixed(2) + 'M'
                : (row.beforeSize / 1024).toFixed(2) + 'KB'
              : '-'
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新后大小" prop="afterSize" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{
            row.afterSize
              ? row.afterSize > 1024
                ? (row.afterSize / 1024 / 1024).toFixed(2) + 'M'
                : (row.afterSize / 1024).toFixed(2) + 'KB'
              : '-'
          }}</span>
        </template>
      </el-table-column>
      <el-table-column label="累计更新次数" prop="modifyCount" show-overflow-tooltip />
      <el-table-column label="操作" show-overflow-tooltip width="120">
        <template #default="{ row }">
          <el-button type="primary" icon="View" link @click="previewFile(row)">查看文件</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" />
  </div>
</template>

<script setup>
import { reactive, ref, onMounted } from 'vue';
import { usePagination } from '@/hooks';
import { documentTypeTree } from '@/api/document/dataClassify';
import { documentModifyHsitoryPage } from '@/api/document/fileManagement/updateRecord';
import { documentAccessRecordAdd } from '@/api/document/fileManagement/loanRecord';
const { proxy } = getCurrentInstance();
const form = reactive({
  typeId: '',
  fileName: '',
});
const treeData = ref([]);
const { pageNum, pageSize, tableData, total, loading, getTableList } = usePagination(documentModifyHsitoryPage, { value: form });

const search = () => {
  pageNum.value = 1;
  getTableList();
};

const resetQuery = () => {
  proxy.$refs.ruleForm.resetFields();
  search();
};

const getTreeData = async () => {
  const res = await documentTypeTree();
  if (res?.code !== 200) return;
  treeData.value = res.data || [];
};

const previewFile = row => {
  const file = row?.sysFileList?.[0] || null;
  if (!file) return;
  window.open(file.url);
  documentAccessRecordAdd({
    fileId: row.fileId,
  });
};

onMounted(() => {
  getTableList();
  getTreeData();
});
</script>

<style lang="scss">
.updateRecord {
  padding: 20px;
  height: 90vh;
  overflow-y: hidden;
  .top {
    margin-bottom: 15px;
  }
}

:deep(.dialog) {
  .el-dialog__body {
    padding-bottom: 20px !important;
  }
  .el-dialog__footer {
    padding-top: 0 !important;
  }
}
.fileTreeSel {
  .el-tree-node__children {
    .el-tree-node__expand-icon {
      visibility: hidden;
    }
  }
}
</style>