|
| 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="name"> |
| 12 | + <el-input |
| 13 | + v-model="queryParams.name" |
| 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-data: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-data: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="name" /> |
| 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="content" /> |
| 90 | + <el-table-column label="备注" align="center" prop="remark" /> |
| 91 | + <el-table-column |
| 92 | + label="创建时间" |
| 93 | + align="center" |
| 94 | + prop="createTime" |
| 95 | + :formatter="dateFormatter" |
| 96 | + width="180px" |
| 97 | + /> |
| 98 | + <el-table-column label="操作" align="center"> |
| 99 | + <template #default="scope"> |
| 100 | + <el-button |
| 101 | + link |
| 102 | + type="primary" |
| 103 | + @click="openForm('update', scope.row.id)" |
| 104 | + v-hasPermi="['report:ureport-data:update']" |
| 105 | + > |
| 106 | + 编辑 |
| 107 | + </el-button> |
| 108 | + <el-button |
| 109 | + link |
| 110 | + type="danger" |
| 111 | + @click="handleDelete(scope.row.id)" |
| 112 | + v-hasPermi="['report:ureport-data:delete']" |
| 113 | + > |
| 114 | + 删除 |
| 115 | + </el-button> |
| 116 | + </template> |
| 117 | + </el-table-column> |
| 118 | + </el-table> |
| 119 | + <!-- 分页 --> |
| 120 | + <Pagination |
| 121 | + :total="total" |
| 122 | + v-model:page="queryParams.pageNo" |
| 123 | + v-model:limit="queryParams.pageSize" |
| 124 | + @pagination="getList" |
| 125 | + /> |
| 126 | + </ContentWrap> |
| 127 | + |
| 128 | + <!-- 表单弹窗:添加/修改 --> |
| 129 | + <UReportDataForm ref="formRef" @success="getList" /> |
| 130 | +</template> |
| 131 | + |
| 132 | +<script setup lang="ts"> |
| 133 | +import { getIntDictOptions, DICT_TYPE } from '@/utils/dict' |
| 134 | +import { dateFormatter } from '@/utils/formatTime' |
| 135 | +import download from '@/utils/download' |
| 136 | +import * as UReportDataApi from '@/api/report/ureport' |
| 137 | +import UReportDataForm from './UReportDataForm.vue' |
| 138 | +
|
| 139 | +defineOptions({ name: 'UReportData' }) |
| 140 | +
|
| 141 | +const message = useMessage() // 消息弹窗 |
| 142 | +const { t } = useI18n() // 国际化 |
| 143 | +
|
| 144 | +const loading = ref(true) // 列表的加载中 |
| 145 | +const list = ref([]) // 列表的数据 |
| 146 | +const total = ref(0) // 列表的总页数 |
| 147 | +const queryParams = reactive({ |
| 148 | + pageNo: 1, |
| 149 | + pageSize: 10, |
| 150 | + name: null, |
| 151 | + status: null, |
| 152 | + remark: null, |
| 153 | + createTime: [], |
| 154 | +}) |
| 155 | +const queryFormRef = ref() // 搜索的表单 |
| 156 | +const exportLoading = ref(false) // 导出的加载中 |
| 157 | +
|
| 158 | +/** 查询列表 */ |
| 159 | +const getList = async () => { |
| 160 | + loading.value = true |
| 161 | + try { |
| 162 | + const data = await UReportDataApi.getUReportDataPage(queryParams) |
| 163 | + list.value = data.list |
| 164 | + total.value = data.total |
| 165 | + } finally { |
| 166 | + loading.value = false |
| 167 | + } |
| 168 | +} |
| 169 | +
|
| 170 | +/** 搜索按钮操作 */ |
| 171 | +const handleQuery = () => { |
| 172 | + queryParams.pageNo = 1 |
| 173 | + getList() |
| 174 | +} |
| 175 | +
|
| 176 | +/** 重置按钮操作 */ |
| 177 | +const resetQuery = () => { |
| 178 | + queryFormRef.value.resetFields() |
| 179 | + handleQuery() |
| 180 | +} |
| 181 | +
|
| 182 | +/** 添加/修改操作 */ |
| 183 | +const formRef = ref() |
| 184 | +const openForm = (type: string, id?: number) => { |
| 185 | + formRef.value.open(type, id) |
| 186 | +} |
| 187 | +
|
| 188 | +/** 删除按钮操作 */ |
| 189 | +const handleDelete = async (id: number) => { |
| 190 | + try { |
| 191 | + // 删除的二次确认 |
| 192 | + await message.delConfirm() |
| 193 | + // 发起删除 |
| 194 | + await UReportDataApi.deleteUReportData(id) |
| 195 | + message.success(t('common.delSuccess')) |
| 196 | + // 刷新列表 |
| 197 | + await getList() |
| 198 | + } catch {} |
| 199 | +} |
| 200 | +
|
| 201 | +/** 导出按钮操作 */ |
| 202 | +const handleExport = async () => { |
| 203 | + try { |
| 204 | + // 导出的二次确认 |
| 205 | + await message.exportConfirm() |
| 206 | + // 发起导出 |
| 207 | + exportLoading.value = true |
| 208 | + const data = await UReportDataApi.exportUReportData(queryParams) |
| 209 | + download.excel(data, 'Ureport2报表.xls') |
| 210 | + } catch { |
| 211 | + } finally { |
| 212 | + exportLoading.value = false |
| 213 | + } |
| 214 | +} |
| 215 | +
|
| 216 | +/** 初始化 **/ |
| 217 | +onMounted(() => { |
| 218 | + getList() |
| 219 | +}) |
| 220 | +</script> |
0 commit comments