feat: ai code
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { SystemUserApi } from '#/api/system/user';
|
||||
|
||||
import { DICT_TYPE } from '@vben/constants';
|
||||
import { getDictOptions } from '@vben/hooks';
|
||||
@@ -7,6 +8,13 @@ import { getDictOptions } from '@vben/hooks';
|
||||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
let userList: SystemUserApi.User[] = [];
|
||||
async function getUserData() {
|
||||
userList = await getSimpleUserList();
|
||||
}
|
||||
|
||||
getUserData();
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
@@ -82,7 +90,10 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
|
||||
{
|
||||
minWidth: 180,
|
||||
title: '用户',
|
||||
slots: { default: 'userId' },
|
||||
field: 'userId',
|
||||
formatter: ({ cellValue }) => {
|
||||
return userList.find((user) => user.id === cellValue)?.nickname || '-';
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'status',
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { AiMusicApi } from '#/api/ai/music';
|
||||
import type { SystemUserApi } from '#/api/system/user';
|
||||
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import { confirm, DocAlert, Page } from '@vben/common-ui';
|
||||
import { AiMusicStatusEnum } from '@vben/constants';
|
||||
@@ -12,12 +9,10 @@ import { Button, message, Switch } from 'ant-design-vue';
|
||||
|
||||
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteMusic, getMusicPage, updateMusic } from '#/api/ai/music';
|
||||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import { useGridColumns, useGridFormSchema } from './data';
|
||||
|
||||
const userList = ref<SystemUserApi.User[]>([]); // 用户列表
|
||||
/** 刷新表格 */
|
||||
function handleRefresh() {
|
||||
gridApi.query();
|
||||
@@ -83,10 +78,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
},
|
||||
} as VxeTableGridOptions<AiMusicApi.Music>,
|
||||
});
|
||||
onMounted(async () => {
|
||||
// 获得下拉数据
|
||||
userList.value = await getSimpleUserList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -99,11 +90,6 @@ onMounted(async () => {
|
||||
<TableAction :actions="[]" />
|
||||
</template>
|
||||
|
||||
<template #userId="{ row }">
|
||||
<span>
|
||||
{{ userList.find((item) => item.id === row.userId)?.nickname }}
|
||||
</span>
|
||||
</template>
|
||||
<template #content="{ row }">
|
||||
<Button
|
||||
type="link"
|
||||
|
||||
Reference in New Issue
Block a user