Newer
Older
KaiFengPC / src / views / document / fileManagement / readAuth / index.vue
@鲁yixuan 鲁yixuan on 19 Aug 5 KB updata
<template>
  <div class="readAuth">
    <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%"
          />
        </el-form-item>
        <el-form-item label="文件标签:" prop="fileTag">
          <el-select v-model="form.fileTag" placeholder="请选择文件标签" clearable multiple style="width: 200px">
            <el-option v-for="dict in document_tag" :key="dict.value" :label="dict.label" :value="dict.value" />
          </el-select>
        </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="authUserNum" show-overflow-tooltip />
      <el-table-column label="资料权属单位" prop="deptName" show-overflow-tooltip />
      <el-table-column label="创建时间" prop="createTime" show-overflow-tooltip />
      <el-table-column label="创建人" prop="nickName" show-overflow-tooltip />
      <el-table-column label="文件标签" prop="fileTagNames" show-overflow-tooltip />
      <el-table-column label="电子档名称" prop="sysFileList" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ row.originalName || '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电子档大小" prop="sysFileList" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ handleFileSize(row.size) || '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="电子档格式" prop="sysFileList" show-overflow-tooltip>
        <template #default="{ row }">
          <span>{{ row.extension || '-' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" show-overflow-tooltip width="100">
        <template #default="{ row }">
          <el-button type="primary" link @click="openDialog(row)">调整权限</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination :total="total" v-model:page="pageNum" v-model:limit="pageSize" @pagination="getTableList" />

    <el-dialog v-model="visible" title="调整权限" :close-on-click-modal="false" width="25%" :before-close="close" class="dialog">
      <operate v-if="visible" ref="operateRef" :cur-row="curRow" @close="close"></operate>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submit">确定</el-button>
          <el-button @click="close">取消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup>
import { reactive, ref, onMounted, computed, shallowRef } from 'vue';
import { optTextMap, statusMap } from '@/utils/map';
import { usePagination } from '@/hooks';
import { handleFileSize } from '@/utils';
import operate from './operate.vue';
import { getDocumentFileList } from '@/api/document/fileManagement/readAuth';
import { documentTypeTree } from '@/api/document/dataClassify';
import { getDocumentFilePage } from '@/api/document/fileManagement/list';
const { proxy } = getCurrentInstance();
const { document_tag } = proxy.useDict('document_tag');

const form = reactive({
  typeId: '',
  fileTag: [],
  fileName: '',
});

const params = computed(() => {
  const fileTag = form.fileTag.join();
  return {
    ...form,
    fileTag,
  };
});

const { pageNum, pageSize, tableData, total, loading, getTableList } = usePagination(getDocumentFilePage, params);

const visible = ref(false);
const curRow = shallowRef({});
const fileList = ref([]);
const treeData = ref([]);

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

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

const openDialog = (data, type) => {
  visible.value = true;
  curRow.value = data;
};

const close = result => {
  if (result.isRefresh) getTableList();
  visible.value = false;
  curRow.value = {};
};

const del = row => {
  proxy.$modal
    .confirm('是否确认删除?')
    .then(async () => {
      const res = await documentFileDel(row.id);
      if (res?.code !== 200) return;
      getTableList();
    })
    .catch(() => {});
};

const submit = () => {
  proxy.$refs.operateRef.submit();
};

const getFileList = async () => {
  const res = await getDocumentFileList();
  if (res?.code !== 200) return;
  fileList.value = res.data || [];
};

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

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

<style lang="scss" scoped>
.readAuth {
  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;
  }
}
</style>