1
+ <template >
2
+ <ContentWrap >
3
+ <!-- 搜索工作栏 -->
4
+ <el-form
5
+ class =" -mb-15px"
6
+ :model =" queryParams"
7
+ ref =" queryFormRef"
8
+ :inline =" true"
9
+ label-width =" 68px"
10
+ >
11
+ <el-form-item label =" 文件名称" prop =" fileName" >
12
+ <el-input
13
+ v-model =" queryParams.fileName"
14
+ placeholder =" 请输入文件名称"
15
+ clearable
16
+ @keyup.enter =" handleQuery"
17
+ class =" !w-240px"
18
+ />
19
+ </el-form-item >
20
+ <el-form-item label =" 状态" prop =" status" >
21
+ <el-select
22
+ v-model =" queryParams.status"
23
+ placeholder =" 请选择状态"
24
+ clearable
25
+ class =" !w-240px"
26
+ >
27
+ <el-option
28
+ v-for =" dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
29
+ :key =" dict.value"
30
+ :label =" dict.label"
31
+ :value =" dict.value"
32
+ />
33
+ </el-select >
34
+ </el-form-item >
35
+ <el-form-item label =" 备注" prop =" remark" >
36
+ <el-input
37
+ v-model =" queryParams.remark"
38
+ placeholder =" 请输入备注"
39
+ clearable
40
+ @keyup.enter =" handleQuery"
41
+ class =" !w-240px"
42
+ />
43
+ </el-form-item >
44
+ <el-form-item label =" 创建时间" prop =" createTime" >
45
+ <el-date-picker
46
+ v-model =" queryParams.createTime"
47
+ value-format =" YYYY-MM-DD HH:mm:ss"
48
+ type =" daterange"
49
+ start-placeholder =" 开始日期"
50
+ end-placeholder =" 结束日期"
51
+ :default-time =" [new Date('1 00:00:00'), new Date('1 23:59:59')]"
52
+ class =" !w-240px"
53
+ />
54
+ </el-form-item >
55
+ <el-form-item >
56
+ <el-button @click =" handleQuery" ><Icon icon =" ep:search" class =" mr-5px" /> 搜索</el-button >
57
+ <el-button @click =" resetQuery" ><Icon icon =" ep:refresh" class =" mr-5px" /> 重置</el-button >
58
+ <el-button
59
+ type =" primary"
60
+ plain
61
+ @click =" openForm('create')"
62
+ v-hasPermi =" ['report:ureport-file:create']"
63
+ >
64
+ <Icon icon =" ep:plus" class =" mr-5px" /> 新增
65
+ </el-button >
66
+ <el-button
67
+ type =" success"
68
+ plain
69
+ @click =" handleExport"
70
+ :loading =" exportLoading"
71
+ v-hasPermi =" ['report:ureport-file:export']"
72
+ >
73
+ <Icon icon =" ep:download" class =" mr-5px" /> 导出
74
+ </el-button >
75
+ </el-form-item >
76
+ </el-form >
77
+ </ContentWrap >
78
+
79
+ <!-- 列表 -->
80
+ <ContentWrap >
81
+ <el-table v-loading =" loading" :data =" list" :stripe =" true" :show-overflow-tooltip =" true" >
82
+ <el-table-column label =" ID" align =" center" prop =" id" />
83
+ <el-table-column label =" 文件名称" align =" center" prop =" fileName" />
84
+ <el-table-column label =" 状态" align =" center" prop =" status" >
85
+ <template #default =" scope " >
86
+ <dict-tag :type =" DICT_TYPE.COMMON_STATUS" :value =" scope.row.status" />
87
+ </template >
88
+ </el-table-column >
89
+ <el-table-column label =" 备注" align =" center" prop =" remark" />
90
+ <el-table-column
91
+ label =" 创建时间"
92
+ align =" center"
93
+ prop =" createTime"
94
+ :formatter =" dateFormatter"
95
+ width =" 180px"
96
+ />
97
+ <el-table-column label =" 操作" align =" center" >
98
+ <template #default =" scope " >
99
+ <el-button
100
+ link
101
+ type =" primary"
102
+ @click =" openForm('update', scope.row.id)"
103
+ v-hasPermi =" ['report:ureport-file:update']"
104
+ >
105
+ 编辑
106
+ </el-button >
107
+ <el-button
108
+ link
109
+ type =" danger"
110
+ @click =" handleDelete(scope.row.id)"
111
+ v-hasPermi =" ['report:ureport-file:delete']"
112
+ >
113
+ 删除
114
+ </el-button >
115
+ </template >
116
+ </el-table-column >
117
+ </el-table >
118
+ <!-- 分页 -->
119
+ <Pagination
120
+ :total =" total"
121
+ v-model:page =" queryParams.pageNo"
122
+ v-model:limit =" queryParams.pageSize"
123
+ @pagination =" getList"
124
+ />
125
+ </ContentWrap >
126
+
127
+ <!-- 表单弹窗:添加/修改 -->
128
+ <UreportFileForm ref =" formRef" @success =" getList" />
129
+ </template >
130
+
131
+ <script setup lang="ts">
132
+ import { getIntDictOptions , DICT_TYPE } from ' @/utils/dict'
133
+ import { dateFormatter } from ' @/utils/formatTime'
134
+ import download from ' @/utils/download'
135
+ import * as UreportFileApi from ' @/api/report/ureport'
136
+ import UreportFileForm from ' ./UreportFileForm.vue'
137
+
138
+ defineOptions ({ name: ' UreportFile' })
139
+
140
+ const message = useMessage () // 消息弹窗
141
+ const { t } = useI18n () // 国际化
142
+
143
+ const loading = ref (true ) // 列表的加载中
144
+ const list = ref ([]) // 列表的数据
145
+ const total = ref (0 ) // 列表的总页数
146
+ const queryParams = reactive ({
147
+ pageNo: 1 ,
148
+ pageSize: 10 ,
149
+ fileName: null ,
150
+ status: null ,
151
+ remark: null ,
152
+ createTime: [],
153
+ })
154
+ const queryFormRef = ref () // 搜索的表单
155
+ const exportLoading = ref (false ) // 导出的加载中
156
+
157
+ /** 查询列表 */
158
+ const getList = async () => {
159
+ loading .value = true
160
+ try {
161
+ const data = await UreportFileApi .getUreportFilePage (queryParams )
162
+ list .value = data .list
163
+ total .value = data .total
164
+ } finally {
165
+ loading .value = false
166
+ }
167
+ }
168
+
169
+ /** 搜索按钮操作 */
170
+ const handleQuery = () => {
171
+ queryParams .pageNo = 1
172
+ getList ()
173
+ }
174
+
175
+ /** 重置按钮操作 */
176
+ const resetQuery = () => {
177
+ queryFormRef .value .resetFields ()
178
+ handleQuery ()
179
+ }
180
+
181
+ /** 添加/修改操作 */
182
+ const formRef = ref ()
183
+ const openForm = (type : string , id ? : number ) => {
184
+ formRef .value .open (type , id )
185
+ }
186
+
187
+ /** 删除按钮操作 */
188
+ const handleDelete = async (id : number ) => {
189
+ try {
190
+ // 删除的二次确认
191
+ await message .delConfirm ()
192
+ // 发起删除
193
+ await UreportFileApi .deleteUreportFile (id )
194
+ message .success (t (' common.delSuccess' ))
195
+ // 刷新列表
196
+ await getList ()
197
+ } catch {}
198
+ }
199
+
200
+ /** 导出按钮操作 */
201
+ const handleExport = async () => {
202
+ try {
203
+ // 导出的二次确认
204
+ await message .exportConfirm ()
205
+ // 发起导出
206
+ exportLoading .value = true
207
+ const data = await UreportFileApi .exportUreportFile (queryParams )
208
+ download .excel (data , ' Ureport2报表.xls' )
209
+ } catch {
210
+ } finally {
211
+ exportLoading .value = false
212
+ }
213
+ }
214
+
215
+ /** 初始化 **/
216
+ onMounted (() => {
217
+ getList ()
218
+ })
219
+ </script >
0 commit comments