提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
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="userId"> |
|
12 |
<el-select |
|
13 |
v-model="queryParams.userId" |
|
14 |
clearable |
|
15 |
placeholder="请输入用户编号" |
|
16 |
class="!w-240px" |
|
17 |
> |
|
18 |
<el-option |
|
19 |
v-for="item in userList" |
|
20 |
:key="item.id" |
|
21 |
:label="item.nickname" |
|
22 |
:value="item.id" |
|
23 |
/> |
|
24 |
</el-select> |
|
25 |
</el-form-item> |
|
26 |
<el-form-item label="平台" prop="platform"> |
|
27 |
<el-select v-model="queryParams.status" placeholder="请选择平台" clearable class="!w-240px"> |
|
28 |
<el-option |
|
29 |
v-for="dict in getStrDictOptions(DICT_TYPE.AI_PLATFORM)" |
|
30 |
:key="dict.value" |
|
31 |
:label="dict.label" |
|
32 |
:value="dict.value" |
|
33 |
/> |
|
34 |
</el-select> |
|
35 |
</el-form-item> |
|
36 |
<el-form-item label="绘画状态" prop="status"> |
|
37 |
<el-select |
|
38 |
v-model="queryParams.status" |
|
39 |
placeholder="请选择绘画状态" |
|
40 |
clearable |
|
41 |
class="!w-240px" |
|
42 |
> |
|
43 |
<el-option |
|
44 |
v-for="dict in getIntDictOptions(DICT_TYPE.AI_IMAGE_STATUS)" |
|
45 |
:key="dict.value" |
|
46 |
:label="dict.label" |
|
47 |
:value="dict.value" |
|
48 |
/> |
|
49 |
</el-select> |
|
50 |
</el-form-item> |
|
51 |
<el-form-item label="是否发布" prop="publicStatus"> |
|
52 |
<el-select |
|
53 |
v-model="queryParams.publicStatus" |
|
54 |
placeholder="请选择是否发布" |
|
55 |
clearable |
|
56 |
class="!w-240px" |
|
57 |
> |
|
58 |
<el-option |
|
59 |
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)" |
|
60 |
:key="dict.value" |
|
61 |
:label="dict.label" |
|
62 |
:value="dict.value" |
|
63 |
/> |
|
64 |
</el-select> |
|
65 |
</el-form-item> |
|
66 |
<el-form-item label="创建时间" prop="createTime"> |
|
67 |
<el-date-picker |
|
68 |
v-model="queryParams.createTime" |
|
69 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
70 |
type="daterange" |
|
71 |
start-placeholder="开始日期" |
|
72 |
end-placeholder="结束日期" |
|
73 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
74 |
class="!w-220px" |
|
75 |
/> |
|
76 |
</el-form-item> |
|
77 |
<el-form-item> |
|
78 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
79 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
80 |
</el-form-item> |
|
81 |
</el-form> |
|
82 |
</ContentWrap> |
|
83 |
|
|
84 |
<!-- 列表 --> |
|
85 |
<ContentWrap> |
|
86 |
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> |
|
87 |
<el-table-column label="编号" align="center" prop="id" width="180" fixed="left" /> |
|
88 |
<el-table-column label="图片" align="center" prop="picUrl" width="110px" fixed="left"> |
|
89 |
<template #default="{ row }"> |
|
90 |
<el-image |
|
91 |
class="h-80px w-80px" |
|
92 |
lazy |
|
93 |
:src="row.picUrl" |
|
94 |
:preview-src-list="[row.picUrl]" |
|
95 |
preview-teleported |
|
96 |
fit="cover" |
|
97 |
v-if="row.picUrl?.length > 0" |
|
98 |
/> |
|
99 |
</template> |
|
100 |
</el-table-column> |
|
101 |
<el-table-column label="用户" align="center" prop="userId" width="180"> |
|
102 |
<template #default="scope"> |
|
103 |
<span>{{ userList.find((item) => item.id === scope.row.userId)?.nickname }}</span> |
|
104 |
</template> |
|
105 |
</el-table-column> |
|
106 |
<el-table-column label="平台" align="center" prop="platform" width="120"> |
|
107 |
<template #default="scope"> |
|
108 |
<dict-tag :type="DICT_TYPE.AI_PLATFORM" :value="scope.row.platform" /> |
|
109 |
</template> |
|
110 |
</el-table-column> |
|
111 |
<el-table-column label="模型" align="center" prop="model" width="180" /> |
|
112 |
<el-table-column label="绘画状态" align="center" prop="status" width="100"> |
|
113 |
<template #default="scope"> |
|
114 |
<dict-tag :type="DICT_TYPE.AI_IMAGE_STATUS" :value="scope.row.status" /> |
|
115 |
</template> |
|
116 |
</el-table-column> |
|
117 |
<el-table-column label="是否发布" align="center" prop="publicStatus"> |
|
118 |
<template #default="scope"> |
|
119 |
<el-switch |
|
120 |
v-model="scope.row.publicStatus" |
|
121 |
:active-value="true" |
|
122 |
:inactive-value="false" |
|
123 |
@change="handleUpdatePublicStatusChange(scope.row)" |
|
124 |
:disabled="scope.row.status !== AiImageStatusEnum.SUCCESS" |
|
125 |
/> |
|
126 |
</template> |
|
127 |
</el-table-column> |
|
128 |
<el-table-column label="提示词" align="center" prop="prompt" width="180" /> |
|
129 |
<el-table-column |
|
130 |
label="创建时间" |
|
131 |
align="center" |
|
132 |
prop="createTime" |
|
133 |
:formatter="dateFormatter" |
|
134 |
width="180px" |
|
135 |
/> |
|
136 |
<el-table-column label="宽度" align="center" prop="width" /> |
|
137 |
<el-table-column label="高度" align="center" prop="height" /> |
|
138 |
<el-table-column label="错误信息" align="center" prop="errorMessage" /> |
|
139 |
<el-table-column label="任务编号" align="center" prop="taskId" /> |
|
140 |
<el-table-column label="操作" align="center" width="100" fixed="right"> |
|
141 |
<template #default="scope"> |
|
142 |
<el-button |
|
143 |
link |
|
144 |
type="danger" |
|
145 |
@click="handleDelete(scope.row.id)" |
|
146 |
v-hasPermi="['ai:image:delete']" |
|
147 |
> |
|
148 |
删除 |
|
149 |
</el-button> |
|
150 |
</template> |
|
151 |
</el-table-column> |
|
152 |
</el-table> |
|
153 |
<!-- 分页 --> |
|
154 |
<Pagination |
|
155 |
:total="total" |
|
156 |
v-model:page="queryParams.pageNo" |
|
157 |
v-model:limit="queryParams.pageSize" |
|
158 |
@pagination="getList" |
|
159 |
/> |
|
160 |
</ContentWrap> |
|
161 |
</template> |
|
162 |
|
|
163 |
<script setup lang="ts"> |
|
164 |
import { getIntDictOptions, DICT_TYPE, getStrDictOptions, getBoolDictOptions } from '@/utils/dict' |
|
165 |
import { dateFormatter } from '@/utils/formatTime' |
|
166 |
import { ImageApi, ImageVO } from '@/api/ai/image' |
|
167 |
import * as UserApi from '@/api/system/user' |
|
168 |
import { AiImageStatusEnum } from '@/views/ai/utils/constants' |
|
169 |
|
|
170 |
/** AI 绘画 列表 */ |
|
171 |
defineOptions({ name: 'AiImageManager' }) |
|
172 |
|
|
173 |
const message = useMessage() // 消息弹窗 |
|
174 |
const { t } = useI18n() // 国际化 |
|
175 |
|
|
176 |
const loading = ref(true) // 列表的加载中 |
|
177 |
const list = ref<ImageVO[]>([]) // 列表的数据 |
|
178 |
const total = ref(0) // 列表的总页数 |
|
179 |
const queryParams = reactive({ |
|
180 |
pageNo: 1, |
|
181 |
pageSize: 10, |
|
182 |
userId: undefined, |
|
183 |
platform: undefined, |
|
184 |
status: undefined, |
|
185 |
publicStatus: undefined, |
|
186 |
createTime: [] |
|
187 |
}) |
|
188 |
const queryFormRef = ref() // 搜索的表单 |
|
189 |
const userList = ref<UserApi.UserVO[]>([]) // 用户列表 |
|
190 |
|
|
191 |
/** 查询列表 */ |
|
192 |
const getList = async () => { |
|
193 |
loading.value = true |
|
194 |
try { |
|
195 |
const data = await ImageApi.getImagePage(queryParams) |
|
196 |
list.value = data.list |
|
197 |
total.value = data.total |
|
198 |
} finally { |
|
199 |
loading.value = false |
|
200 |
} |
|
201 |
} |
|
202 |
|
|
203 |
/** 搜索按钮操作 */ |
|
204 |
const handleQuery = () => { |
|
205 |
queryParams.pageNo = 1 |
|
206 |
getList() |
|
207 |
} |
|
208 |
|
|
209 |
/** 重置按钮操作 */ |
|
210 |
const resetQuery = () => { |
|
211 |
queryFormRef.value.resetFields() |
|
212 |
handleQuery() |
|
213 |
} |
|
214 |
|
|
215 |
/** 删除按钮操作 */ |
|
216 |
const handleDelete = async (id: number) => { |
|
217 |
try { |
|
218 |
// 删除的二次确认 |
|
219 |
await message.delConfirm() |
|
220 |
// 发起删除 |
|
221 |
await ImageApi.deleteImage(id) |
|
222 |
message.success(t('common.delSuccess')) |
|
223 |
// 刷新列表 |
|
224 |
await getList() |
|
225 |
} catch {} |
|
226 |
} |
|
227 |
|
|
228 |
/** 修改是否发布 */ |
|
229 |
const handleUpdatePublicStatusChange = async (row: ImageVO) => { |
|
230 |
try { |
|
231 |
// 修改状态的二次确认 |
|
232 |
const text = row.publicStatus ? '公开' : '私有' |
|
233 |
await message.confirm('确认要"' + text + '"该图片吗?') |
|
234 |
// 发起修改状态 |
|
235 |
await ImageApi.updateImage({ |
|
236 |
id: row.id, |
|
237 |
publicStatus: row.publicStatus |
|
238 |
}) |
|
239 |
await getList() |
|
240 |
} catch { |
|
241 |
row.publicStatus = !row.publicStatus |
|
242 |
} |
|
243 |
} |
|
244 |
|
|
245 |
/** 初始化 **/ |
|
246 |
onMounted(async () => { |
|
247 |
getList() |
|
248 |
// 获得用户列表 |
|
249 |
userList.value = await UserApi.getSimpleUserList() |
|
250 |
}) |
|
251 |
</script> |