zhouwx
2024-06-12 bcc1ce55aa699450905c68f957198428ed251c48
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
  <div class="app-container">
    <div style="margin-bottom: 10px">
      <el-button
          type="primary"
          plain
          icon="Plus"
          @click="openDialog('add',{})"
      >新增</el-button>
      <span style="font-size: 15px;color: #ed5565;margin-left: 15px">补录今年1-6月的历史项目</span>
    </div>
 
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
      <el-table-column label="项目名称" prop="name" align="center" width="180" />
      <el-table-column label="项目时间" prop="filingDate" align="center" :show-overflow-tooltip="true"  />
      <el-table-column label="报告撰写人" prop="writer" align="center" :show-overflow-tooltip="true"  />
      <el-table-column label="报告审批人" prop="reviewer" align="center" width="200" />
      <el-table-column label="报告扫描件"  align="center" >
        <template #default="scope">
          <div v-for="(item,index) in scope.row.files" :key="index">
            <span style="color: #1890ff;cursor: pointer" @click="showFile(item)">{{item.originName}}</span>
          </div>
 
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" >
        <template #default="scope">
          <el-button link type="primary"  @click="openDialog('review',scope.row)" >查看</el-button>
          <el-button link type="primary"  @click="openDialog('edit',scope.row)" >编辑</el-button>
          <el-button link type="danger"  @click="handleDelete(scope.row)" >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
 
    <div class="pag-container">
      <el-pagination
          v-model:current-page="data.queryParams.pageNum"
          v-model:page-size="data.queryParams.pageSize"
          :page-sizes="[10,15,20,25]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
      />
    </div>
    <suppleDialog ref="dRef" @getList="getList"></suppleDialog>
  </div>
</template>
 
<script setup>
import {getCurrentInstance, onMounted, reactive, ref, toRefs} from "vue";
import suppleDialog from './components/supplemenrtDialog.vue'
import {ElMessage, ElMessageBox} from "element-plus";
import {delSupplement, getSupplementList} from "@/api/backManage/supplement";
import axios from "axios";
import {getToken} from "@/utils/auth";
const { proxy } = getCurrentInstance();
const loading = ref(false);
const dRef = ref();
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
  total: 0,
  dataList: []
});
 
const { queryParams, total, dataList } = toRefs(data);
 
onMounted(() => {
  getList();
});
const getList = async () => {
  loading.value = true;
  const res = await getSupplementList(data.queryParams);
  if(res.code === 200){
    dataList.value = res.data.list.map(item => {
      return {
        ...item,
        filingDate: item.filingDate.substring(0,10),
        files: item.files.map(f => {
          return {
            ...f,
            type:f.originName.substring(f.originName.lastIndexOf(".") + 1)
          }
        })
      }
    })
    console.log("dataList.value",dataList.value)
    total.value = res.data.total
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false;
}
const handleSizeChange = (val) => {
  data.queryParams.pageNum = 1
  data.queryParams.pageSize = val
  getList()
}
const handleCurrentChange = (val) => {
  data.queryParams.pageNum = val
  getList()
}
 
const openDialog = (type, value) => {
  dRef.value.openDialog(type, value);
}
 
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delSupplement(val);
        if(res.code === 200){
          ElMessage({
            type: 'success',
            message: '删除成功'
          });
         await getList();
        }else{
          ElMessage.warning(res.message)
        }
      })
}
const showFile = (file) => {
  let path = "";
  if(file.path){
    path = file.path
  }else {
    path = file.response.data.path
 
  }
  const url = import.meta.env.VITE_APP_BASE_API + '/' + path
  axios.get( url,{
        headers:
            {
              'Content-Type': 'application/json',
              'Authorization':getToken(),
            },
        responseType: 'blob'
      }
  ).then(res=>{
    if (res) {
      const link = document.createElement('a')
      let blob = new Blob([res.data],{type: res.data.type})
      link.style.display = "none";
      link.href = URL.createObjectURL(blob); // 创建URL
      link.setAttribute("download", file.originName);
      document.body.appendChild(link);
      link.click();
      document.body.removeChild(link);
    } else {
      this.$message.error('获取文件失败')
    }
  })
}
 
</script>
<style lang="scss">
.pag-container{
  float: right;
  margin-top: 10px;
}
</style>