generated from Leo_Ding/web-template
222 lines
8.2 KiB
Vue
222 lines
8.2 KiB
Vue
<template>
|
|
<a-row :gutter="8" :wrap="false">
|
|
<a-col flex="auto">
|
|
<a-card type="flex">
|
|
<x-action-bar class="mb-8-2">
|
|
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
|
<template #icon>
|
|
<plus-outlined></plus-outlined>
|
|
</template>
|
|
新增
|
|
</a-button>
|
|
</x-action-bar>
|
|
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
|
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
|
<template #bodyCell="{ column, record }">
|
|
<template v-if="'imagePath' === column.dataIndex">
|
|
<a-image :width="60"
|
|
:src="record.imagePath ? config('http.apiBasic') + record.imagePath : errImg" />
|
|
</template>
|
|
<template v-if="'icon' === column.dataIndex">
|
|
<a-image :width="60" :src="record.icon ? config('http.apiBasic') + record.icon : errImg" />
|
|
</template>
|
|
<template v-if="'background' === column.dataIndex">
|
|
<a-image :width="60"
|
|
:src="record.background ? config('http.apiBasic') + record.background : errImg" />
|
|
</template>
|
|
|
|
<template v-if="'status' === column.dataIndex">
|
|
<a-tag :color="aiStatus.getColor(record.status)">{{ aiStatus.getName(record.status)
|
|
}}</a-tag>
|
|
</template>
|
|
<template v-if="'action' === column.key">
|
|
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
|
<a-tooltip>
|
|
<template #title> {{ $t('pages.system.user.edit') }}</template>
|
|
<edit-outlined /> </a-tooltip></x-action-button>
|
|
<x-action-button @click="auditHandleEdit(record, 'audit')" v-if="record.status === 1">
|
|
<a-tooltip>
|
|
<template #title> {{ '审核' }}</template>
|
|
<i class='iconfont icon-shenhe' style='font-size:14px;color:#faad14'></i>
|
|
</a-tooltip>
|
|
</x-action-button>
|
|
<x-action-button @click="handleDelete(record)">
|
|
<a-tooltip>
|
|
<template #title>{{ $t('pages.system.delete') }}</template>
|
|
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
|
</template>
|
|
</template>
|
|
</a-table>
|
|
</a-card>
|
|
</a-col>
|
|
</a-row>
|
|
<a-modal :open="open" :title="'审核'" :width="640" title="审核" ok-text="确认" cancel-text="取消" @ok="handleAuditEdit"
|
|
@cancel="open = false">
|
|
<a-card class="mb-8-2">
|
|
<a-form-item :label="'审核'" name="">
|
|
<a-radio-group v-model:value="auditStatus"
|
|
:options="[{ value: 2, label: '通过' }, { value: 99, label: '不通过' }]"></a-radio-group>
|
|
</a-form-item>
|
|
<a-form-item :label="'备注'" name="">
|
|
<a-textarea v-model:value="remark"></a-textarea>
|
|
</a-form-item>
|
|
</a-card>
|
|
</a-modal>
|
|
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { message, Modal } from 'ant-design-vue'
|
|
import { ref } from 'vue'
|
|
import apis from '@/apis'
|
|
import { formatUtcDateTime } from '@/utils/util'
|
|
import { config } from '@/config'
|
|
import { statusUserTypeEnum } from '@/enums/system'
|
|
import { usePagination } from '@/hooks'
|
|
import errImg from '@/assets/blankSpace.png'
|
|
import EditDialog from './components/EditDialog.vue'
|
|
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
|
import { useI18n } from 'vue-i18n'
|
|
import { delMenu, getDataList } from '@/apis/modules/aiRequest'
|
|
import { aiStatus } from '@/enums/index.js'
|
|
defineOptions({
|
|
name: 'ai_helper',
|
|
})
|
|
const currentForm = ref({})
|
|
const open = ref(false)
|
|
const auditStatus = ref(2)
|
|
const remark = ref('')
|
|
const { t } = useI18n() // 解构出t方法
|
|
const columns = [
|
|
{ title: '名称', dataIndex: 'name', key: 'name' },
|
|
{ title: '描述', dataIndex: 'description', key: 'description' },
|
|
{ title: '封面', dataIndex: 'imagePath', width: 100, align: 'center' },
|
|
{ title: '头像', dataIndex: 'icon', width: 100, align: 'center' },
|
|
{ title: '背景图', dataIndex: 'background', align: 'center' },
|
|
{ title: '服务地址', dataIndex: 'serviceUrl', align: 'center' },
|
|
{ title: 'APIKKEY', dataIndex: 'apiKey', align: 'center' },
|
|
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
|
// { title: '备注', dataIndex: 'remark', align: 'center' },
|
|
{ title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
|
|
{ title: t('button.action'), key: 'action', fixed: 'right', width: 140, align: 'center' },
|
|
]
|
|
|
|
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = usePagination()
|
|
|
|
const editDialogRef = ref()
|
|
getPageList()
|
|
/**
|
|
* 获取用户列表
|
|
* @returns {Promise<void>}
|
|
*/
|
|
|
|
async function getPageList() {
|
|
try {
|
|
showLoading()
|
|
const { pageSize, current } = paginationState
|
|
const { success, data, total } = await apis.aiRequest
|
|
.getDataList({
|
|
pageSize,
|
|
current: current,
|
|
scene: 1,
|
|
...searchFormData.value,
|
|
})
|
|
.catch(() => {
|
|
throw new Error()
|
|
})
|
|
hideLoading()
|
|
if (config('http.code.success') === success) {
|
|
//筛选type的值80对应about
|
|
listData.value = data
|
|
paginationState.total = total
|
|
}
|
|
} catch (error) {
|
|
hideLoading()
|
|
}
|
|
}
|
|
const auditHandleEdit = (params) => {
|
|
currentForm.value = params
|
|
open.value = true
|
|
}
|
|
const handleAuditEdit = async () => {
|
|
try {
|
|
const params = {
|
|
...currentForm.value,
|
|
status: auditStatus.value,
|
|
remark: remark.value
|
|
}
|
|
const result = await apis.aiRequest.updateMenu(currentForm.value.id, params).catch(() => {
|
|
throw new Error()
|
|
})
|
|
if (config('http.code.success') === result?.success) {
|
|
getPageList()
|
|
open.value = false
|
|
message.success('审核成功')
|
|
}
|
|
} catch (error) {
|
|
message.error(error.message)
|
|
}
|
|
}
|
|
/**
|
|
* 删除
|
|
*/
|
|
function handleDelete({ id }) {
|
|
Modal.confirm({
|
|
title: t('pages.system.user.delTip'),
|
|
content: t('button.confirm'),
|
|
okText: t('button.confirm'),
|
|
onOk: () => {
|
|
return new Promise((resolve, reject) => {
|
|
; (async () => {
|
|
try {
|
|
const { success } = await apis.aiRequest.delMenu(id).catch(() => {
|
|
throw new Error()
|
|
})
|
|
if (config('http.code.success') === success) {
|
|
resolve()
|
|
message.success(t('component.message.success.delete'))
|
|
await getPageList()
|
|
}
|
|
} catch (error) {
|
|
reject()
|
|
}
|
|
})()
|
|
})
|
|
},
|
|
})
|
|
}
|
|
|
|
/**
|
|
* 分页
|
|
*/
|
|
function onTableChange({ current, pageSize }) {
|
|
paginationState.current = current
|
|
paginationState.pageSize = pageSize
|
|
getPageList()
|
|
}
|
|
|
|
/**
|
|
* 搜索
|
|
*/
|
|
function handleSearch() {
|
|
resetPagination()
|
|
getPageList()
|
|
}
|
|
/**
|
|
* 重置
|
|
*/
|
|
function handleResetSearch() {
|
|
searchFormData.value = {}
|
|
resetPagination()
|
|
getPageList()
|
|
}
|
|
/**
|
|
* 编辑完成
|
|
*/
|
|
async function onOk() {
|
|
await getPageList()
|
|
}
|
|
</script>
|
|
|
|
<style lang="less" scoped></style>
|