即将修改网站-联系我们

This commit is contained in:
qingyu 2025-06-22 15:44:53 +08:00
parent cd01496a5c
commit eba02405d8
16 changed files with 878 additions and 1310 deletions

View File

@ -0,0 +1,14 @@
/**
* 海邻大事记动态接口
*/
import request from '@/utils/request'
// 获取菜单列表
export const getDataList = (params) => request.basic.get('/api/v1/memorabilias', params)
// 获取菜单条数据
export const getMenu = (id) => request.basic.get(`/api/v1/memorabilias/${id}`)
// 添加菜单
export const createMenu = (params) => request.basic.post('/api/v1/memorabilias', params)
// 更新菜单
export const updateMenu = (id, params) => request.basic.put(`/api/v1/memorabilias/${id}`, params)
// 删除菜单
export const delMenu = (id) => request.basic.delete(`/api/v1/memorabilias/${id}`)

14
src/apis/modules/team.js Normal file
View File

@ -0,0 +1,14 @@
/**
* 海邻动态接口
*/
import request from '@/utils/request'
// 获取菜单列表
export const getDataList = (params) => request.basic.get('/api/v1/teams', params)
// 获取菜单条数据
export const getMenu = (id) => request.basic.get(`/api/v1/teams/${id}`)
// 添加菜单
export const createMenu = (params) => request.basic.post('/api/v1/teams', params)
// 更新菜单
export const updateMenu = (id, params) => request.basic.put(`/api/v1/teams/${id}`, params)
// 删除菜单
export const delMenu = (id) => request.basic.delete(`/api/v1/teams/${id}`)

View File

@ -0,0 +1,14 @@
/**
* 海邻动态接口
*/
import request from '@/utils/request'
// 获取公司动态列表
export const getDataList = (params) => request.basic.get('/api/v1/videos', params)
// 获取单条数据
export const getItem = (id) => request.basic.get(`/api/v1/videos/${id}`)
// 添加动态
export const createDynamic = (params) => request.basic.post('/api/v1/videos', params)
// 更新动态
export const updateItem = (id, params) => request.basic.put(`/api/v1/videos/${id}`, params)
// 删除动态
export const delItem = (id) => request.basic.delete(`/api/v1/videos/${id}`)

View File

@ -0,0 +1,14 @@
/**
* 海邻大事记动态接口
*/
import request from '@/utils/request'
// 获取菜单列表
export const getDataList = (params) => request.basic.get('/api/v1/web_site', params)
// 获取菜单条数据
export const getMenu = (id) => request.basic.get(`/api/v1/web_site/${id}`)
// 添加菜单
export const createMenu = (params) => request.basic.post('/api/v1/web_site', params)
// 更新菜单
export const updateMenu = (id, params) => request.basic.put(`/api/v1/web_site/${id}`, params)
// 删除菜单
export const delMenu = (id) => request.basic.delete(`/api/v1/web_site/${id}`)

View File

@ -100,7 +100,7 @@ import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
defineOptions({ defineOptions({
name: 'homeBanner', name: 'companyNews',
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
const columns = [ const columns = [
@ -137,7 +137,7 @@ async function getPageList() {
}) })
hideLoading() hideLoading()
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
listData.value = data listData.value = data.filter(item => item.type === "news")
paginationState.total = total paginationState.total = total
} }
} catch (error) { } catch (error) {

View File

@ -1,112 +1,41 @@
<template> <template>
<a-modal <a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
:open="modal.open" :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
:title="modal.title" <a-form ref="formRef" :model="formData" :rules="formRules">
:width="640"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ style: { width: '90px' } }">
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.username')"
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="formData.username"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.password')"
name="password">
<a-input-password
v-model:value="formData.password"
:placeholder="$t('pages.system.user.form.password.placeholder')" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.name')"
name="name">
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="formData.name"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.roles')"
name="roles">
<a-select
v-model:value="formData.roles"
mode="multiple"
style="width: 100%"
:placeholder="$t('pages.system.user.form.roles.placeholder')"
:options="roles"
@change="handleChange"></a-select>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.phone')"
type="tel"
name="phone">
<a-input
:placeholder="$t('pages.system.user.form.phone.placeholder')"
type="tel"
v-model:value="formData.phone"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.email')"
type="email"
name="email">
<a-input
:placeholder="$t('pages.system.user.form.email.placeholder')"
type="email"
v-model:value="formData.email"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'标题'" name="title">
:label="$t('pages.system.user.form.remark')" <a-input :placeholder="'请输入标题'" v-model:value="formData.title"></a-input>
name="remark">
<a-textarea
:placeholder="$t('pages.system.user.form.remark.placeholder')"
v-model:value="formData.remark"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'内容'" name="content">
:label="$t('pages.system.user.form.status')" <a-textarea :placeholder="'内容'" v-model:value="formData.content"></a-textarea>
name="status"> </a-form-item>
<a-radio-group </a-col>
v-model:value="formData.status" <a-col :span="24">
:options="[ <a-form-item :label="'链接'" name="link">
{ label: $t('pages.system.user.form.status.activated'), value: 'activated' }, <a-input v-model:value="formData.link" :placeholder="'请输入链接'" />
{ label: $t('pages.system.user.form.status.freezed'), value: 'freezed' }, </a-form-item>
]"></a-radio-group> </a-col>
<a-col :span="24">
<a-form-item :label="'日期'" name="pushAt">
<a-date-picker v-model:value="formData.pushAt" :format="'YYYY-MM-DD'" placeholder="选择日期" style="width: 100%;">
</a-date-picker>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'状态'" name="status">
<a-radio-group v-model:value="formData.status" :options="[
{ label: '启用', value: 'enabled' },
{ label: '停用', value: 'disabled' },
]"></a-radio-group>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'图片'" name="imgUrl">
<x-upload-image v-model="imgUrl" @imgChange="imgChange" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -123,6 +52,7 @@ import apis from '@/apis'
import { useForm, useModal } from '@/hooks' import { useForm, useModal } from '@/hooks'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
const { t } = useI18n() // t const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
@ -131,18 +61,18 @@ const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm')) const okText = ref(t('button.confirm'))
const rolesValue = ref([]) const rolesValue = ref([])
const roles = ref([]) const roles = ref([])
const imgUrl = ref('')
formRules.value = { formRules.value = {
name: { required: true, message: t('pages.system.user.form.username.placeholder') }, title: { required: true, message: '请输入标题' },
username: { required: true, message: t('pages.system.user.form.code.placeholder') }, content: { required: true, message: '请输入内容' },
status: { required: true, message: t('pages.system.user.form.status') }, link: { required: true, message: '请输入链接' },
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }], status: [{ required: true, message: '请选择状态', trigger: 'change' }],
pushAt: [{ required: true, message: '请选择发布日期', trigger: 'change' }],
// imgUrl: [{ required: true, message: '', trigger: 'change' }],
} }
/**
* 请求角色
*/
getRole()
/** /**
* select 选择框 * select 选择框
@ -150,34 +80,21 @@ getRole()
const handleChange = (value) => { const handleChange = (value) => {
rolesValue.value = value rolesValue.value = value
} }
const imgChange = (value) => {
formData.value.img = value
}
/** /**
* 新建 * 新建
*/ */
function handleCreate() { function handleCreate() {
showModal({ showModal({
type: 'create', type: 'create',
title: t('pages.system.user.add'), title: '添加公司动态',
}) })
formData.value.status = 'enabled'
} }
async function getRole() {
const { success, data } = await apis.role.getRoleList().catch(() => {
throw new Error()
})
if (!success) {
return message.error('当前角色信息错误')
}
let roleArr = []
if (data.length) {
data.forEach((item) => {
roleArr.push({
label: item.name,
value: item.id,
})
})
}
roles.value = roleArr
}
/** /**
* 编辑 * 编辑
*/ */
@ -186,58 +103,58 @@ async function handleEdit(record = {}) {
type: 'edit', type: 'edit',
title: t('pages.system.user.edit'), title: t('pages.system.user.edit'),
}) })
const { data, success } = await apis.users.getUsers(record.id).catch() const { data, success } = await apis.dynamic.getItem(record.id).catch()
if (!success) { if (!success) {
hideModal() hideModal()
return return
} }
let roles = [] formData.value = { ...data }
if (data.roles) { formData.value.pushAt=dayjs(data.pushAt)
roles = formatArr(data.roles, 'edit') console.log(formData.value)
} imgUrl.value = config('http.apiBasic') + data.img
data.roles = roles
formRecord.value = data
formData.value = cloneDeep(data)
} }
/** /**
* 确定 * 确定
*/ */
function handleOk() { function handleOk() {
formRef.value if (!formData.value.img) return message.error('请上传图片');
.validateFields() formRef.value.validateFields().then(async (values) => {
.then(async (values) => { console.log(values)
try { try {
showLoading() showLoading()
const params = {
const params = { ...values,
...values, img: formData.value.img,
roles: formatArr(rolesValue.value), pushAt:dayjs(formData.value.pushAt).format("YYYY-MM-DD"),
} type: 'banner'
let result = null
switch (modal.value.type) {
case 'create':
result = await apis.users.createUsers(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
} }
}) let result = null
.catch(() => { console.log(modal.value.type)
switch (modal.value.type) {
case 'create':
result = await apis.dynamic.createDynamic(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.dynamic.updateItem(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
console.log(error)
hideLoading()
}
})
.catch((e) => {
console.log(e)
hideLoading() hideLoading()
}) })
} }
@ -273,6 +190,7 @@ function formatArr(data, type = '') {
* 取消 * 取消
*/ */
function handleCancel() { function handleCancel() {
imgUrl.value = ''
hideModal() hideModal()
} }

View File

@ -1,44 +1,28 @@
<template> <template>
<x-search-bar class="mb-8-2"> <x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }"> <template #default="{ gutter, colSpan }">
<a-form <a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
:label-col="{ style: { width: '100px' } }"
:model="searchFormData"
layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item <a-form-item label="标题" name="title">
:label="$t('pages.system.user.form.username')" <a-input placeholder="请输入媒体动态标题" v-model:value="searchFormData.title"></a-input>
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="searchFormData.username"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item name="name"> <a-form-item label="状态" name="status">
<template #label> <a-select v-model:value="searchFormData.status" allowClear>
{{ $t('pages.system.user.form.name') }} <a-select-option value="">全部</a-select-option>
<a-tooltip :title="$t('pages.system.user.form.name')"> <a-select-option value="enabled">启用</a-select-option>
<question-circle-outlined class="ml-4-1 color-placeholder" /> <a-select-option value="disabled">停用</a-select-option>
</a-tooltip> </a-select>
</template>
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="searchFormData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col <a-col class="align-right" v-bind="colSpan">
class="align-right"
v-bind="colSpan">
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button <a-button ghost type="primary" @click="handleSearch">
ghost
type="primary"
@click="handleSearch">
{{ $t('button.search') }} {{ $t('button.search') }}
</a-button> </a-button>
</a-space> </a-space>
@ -47,58 +31,52 @@
</a-form> </a-form>
</template> </template>
</x-search-bar> </x-search-bar>
<a-row <a-row :gutter="8" :wrap="false">
:gutter="8"
:wrap="false">
<a-col flex="auto"> <a-col flex="auto">
<a-card type="flex"> <a-card type="flex">
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button <a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
type="primary"
@click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
{{ $t('pages.system.user.add') }} 新增动态
</a-button> </a-button>
</x-action-bar> </x-action-bar>
<a-table <a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:columns="columns" :pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
:data-source="listData"
:loading="loading"
:pagination="paginationState"
:scroll="{ x: 1000 }"
@change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'statusType' === column.key"> <template v-if="'img' === column.dataIndex">
<!--状态--> <a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
<a-tag
v-if="statusUserTypeEnum.is('activated', record.status)"
color="processing">
{{ statusUserTypeEnum.getDesc(record.status) }}
</a-tag>
<!--状态-->
<a-tag
v-if="statusUserTypeEnum.is('freezed', record.status)"
color="processing">
{{ statusUserTypeEnum.getDesc(record.status) }}
</a-tag>
</template> </template>
<template v-if="column.dataIndex === 'title'">
<template v-if="'createAt' === column.key"> <a-tooltip :title="record.title">
{{ formatUtcDateTime(record.created_at) }} <span>{{ record.title }}</span>
</a-tooltip>
</template>
<template v-if="column.dataIndex === 'content'">
<a-tooltip :title="record.content">
<span>{{ record.content }}</span>
</a-tooltip>
</template>
<template v-if="column.dataIndex === 'link'">
<a-tooltip :title="record.link">
<a :href="record.link" target="_blank" style="text-decoration: underline;">{{
record.link }}</a>
</a-tooltip>
</template>
<template v-if="'status' === column.dataIndex">
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.user.edit') }}</template> <template #title> {{ $t('pages.system.user.edit') }}</template>
<edit-outlined /> </a-tooltip <edit-outlined /> </a-tooltip></x-action-button>
></x-action-button>
<x-action-button @click="handleDelete(record)"> <x-action-button @click="handleDelete(record)">
<a-tooltip> <a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template> <template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip <delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
></x-action-button>
</template> </template>
</template> </template>
</a-table> </a-table>
@ -106,9 +84,7 @@
</a-col> </a-col>
</a-row> </a-row>
<edit-dialog <edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
ref="editDialogRef"
@ok="onOk"></edit-dialog>
</template> </template>
<script setup> <script setup>
@ -128,13 +104,13 @@ defineOptions({
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
const columns = [ const columns = [
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 }, { title: '图片', dataIndex: 'img', width: 100, align: 'center' },
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 }, { title: '标题', dataIndex: 'title', key: 'title' },
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 }, { title: '简介', dataIndex: 'content', key: 'content' },
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 }, { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 }, { title: '发布日期', dataIndex: 'pushAt', width: 120, align: 'center' },
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 }, { title: '链接', dataIndex: 'link', align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 }, { title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
] ]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
@ -150,8 +126,8 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { success, data, total } = await apis.users const { success, data, total } = await apis.dynamic
.getUsersList({ .getDataList({
pageSize, pageSize,
page: current, page: current,
...searchFormData.value, ...searchFormData.value,
@ -161,7 +137,7 @@ async function getPageList() {
}) })
hideLoading() hideLoading()
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
listData.value = data listData.value = data.filter(item => item.type === "banner")
paginationState.total = total paginationState.total = total
} }
} catch (error) { } catch (error) {
@ -179,9 +155,9 @@ function handleDelete({ id }) {
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
;(async () => { ; (async () => {
try { try {
const { success } = await apis.users.delUsers(id).catch(() => { const { success } = await apis.dynamic.delItem(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {

View File

@ -1,114 +1,70 @@
<template> <template>
<a-modal <a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
:open="modal.open" :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
:title="modal.title" <a-form ref="formRef" :model="formData" :rules="formRules">
:width="640"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ style: { width: '90px' } }">
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.username')"
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="formData.username"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.password')"
name="password">
<a-input-password
v-model:value="formData.password"
:placeholder="$t('pages.system.user.form.password.placeholder')" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.name')"
name="name">
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="formData.name"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.roles')"
name="roles">
<a-select
v-model:value="formData.roles"
mode="multiple"
style="width: 100%"
:placeholder="$t('pages.system.user.form.roles.placeholder')"
:options="roles"
@change="handleChange"></a-select>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.phone')"
type="tel"
name="phone">
<a-input
:placeholder="$t('pages.system.user.form.phone.placeholder')"
type="tel"
v-model:value="formData.phone"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.email')"
type="email"
name="email">
<a-input
:placeholder="$t('pages.system.user.form.email.placeholder')"
type="email"
v-model:value="formData.email"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'标题'" name="title">
:label="$t('pages.system.user.form.remark')" <a-input :placeholder="'请输入标题'" v-model:value="formData.title"></a-input>
name="remark">
<a-textarea
:placeholder="$t('pages.system.user.form.remark.placeholder')"
v-model:value="formData.remark"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'内容'" name="subheading">
:label="$t('pages.system.user.form.status')" <!-- <a-textarea :placeholder="'内容'" v-model:value="formData.subheading"></a-textarea>-->
name="status"> <a-textarea :placeholder="'内容'" v-model:value="formData.subheading"></a-textarea>
<a-radio-group
v-model:value="formData.status"
:options="[
{ label: $t('pages.system.user.form.status.activated'), value: 'activated' },
{ label: $t('pages.system.user.form.status.freezed'), value: 'freezed' },
]"></a-radio-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="24">
<a-form-item :label="'链接'" name="link">
<a-input v-model:value="formData.link" :placeholder="'请输入链接'" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'日期'" name="pushAt">
<a-date-picker v-model:value="formData.pushAt" :format="'YYYY-MM-DD'" placeholder="选择日期" style="width: 100%;">
</a-date-picker>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'状态'" name="status">
<a-radio-group v-model:value="formData.status" :options="[
{ label: '启用', value: 'enabled' },
{ label: '停用', value: 'disabled' },
]"></a-radio-group>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'大图片'" name="fullImg">
<x-upload-image v-model="fullImg" @imgChange="imgChange" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'小图片'" name="smallImg">
<x-upload-image v-model="smallImg" @imgChange="imgChange" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="视频" name="videoUrl">
<a-upload
:action="uploadUrl"
:show-upload-list="false"
:before-upload="beforeUpload"
:on-success="handleUploadSuccess"
:accept="'video/*'"
>
<a-button type="primary">上传视频</a-button>
</a-upload>
<video
v-if="formData.videoUrl"
:src="formData.videoUrl"
controls
style="margin-top: 10px; width: 100%; max-width: 600px;"
/>
</a-form-item>
</a-col>
</a-row> </a-row>
</a-card> </a-card>
</a-form> </a-form>
@ -123,6 +79,7 @@ import apis from '@/apis'
import { useForm, useModal } from '@/hooks' import { useForm, useModal } from '@/hooks'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
const { t } = useI18n() // t const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
@ -131,18 +88,22 @@ const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm')) const okText = ref(t('button.confirm'))
const rolesValue = ref([]) const rolesValue = ref([])
const roles = ref([]) const roles = ref([])
const imgUrl = ref('')
const fullImg = ref('')
const smallImg = ref('')
const videoUrl = ref('')
formRules.value = { formRules.value = {
name: { required: true, message: t('pages.system.user.form.username.placeholder') }, title: { required: true, message: '请输入标题' },
username: { required: true, message: t('pages.system.user.form.code.placeholder') }, subheading: { required: true, message: '请输入内容' },
status: { required: true, message: t('pages.system.user.form.status') }, link: { required: true, message: '请输入链接' },
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }], status: [{ required: true, message: '请选择状态', trigger: 'change' }],
pushAt: [{ required: true, message: '请选择发布日期', trigger: 'change' }],
fullImg: [{ required: false, message: '请上传大图片', trigger: 'change' }],
smallImg: [{ required: false, message: '请上传小图片', trigger: 'change' }],
videoUrl: [{ required: false, message: '请上传视频', trigger: 'change' }],
} }
/**
* 请求角色
*/
getRole()
/** /**
* select 选择框 * select 选择框
@ -150,34 +111,24 @@ getRole()
const handleChange = (value) => { const handleChange = (value) => {
rolesValue.value = value rolesValue.value = value
} }
const imgChange = (value) => {
formData.value.img = value
formData.value.fullImg = value
formData.value.samllImg = value
formData.value.videoUrl = value
}
/** /**
* 新建 * 新建
*/ */
function handleCreate() { function handleCreate() {
showModal({ showModal({
type: 'create', type: 'create',
title: t('pages.system.user.add'), title: '添加公司动态',
}) })
formData.value.status = 'enabled'
} }
async function getRole() {
const { success, data } = await apis.role.getRoleList().catch(() => {
throw new Error()
})
if (!success) {
return message.error('当前角色信息错误')
}
let roleArr = []
if (data.length) {
data.forEach((item) => {
roleArr.push({
label: item.name,
value: item.id,
})
})
}
roles.value = roleArr
}
/** /**
* 编辑 * 编辑
*/ */
@ -186,58 +137,63 @@ async function handleEdit(record = {}) {
type: 'edit', type: 'edit',
title: t('pages.system.user.edit'), title: t('pages.system.user.edit'),
}) })
const { data, success } = await apis.users.getUsers(record.id).catch() const { data, success } = await apis.videoCenter.getItem(record.id).catch()
if (!success) { if (!success) {
hideModal() hideModal()
return return
} }
let roles = [] formData.value = { ...data }
if (data.roles) { formData.value.pushAt=dayjs(data.pushAt)
roles = formatArr(data.roles, 'edit') console.log(formData.value)
} imgUrl.value = config('http.apiBasic') + data.img
smallImg.value = config('http.apiBasic') + data.img
data.roles = roles fullImg.value = config('http.apiBasic') + data.img
formRecord.value = data videoUrl.value = config('http.apiBasic') + data.mp4
formData.value = cloneDeep(data)
} }
/** /**
* 确定 * 确定
*/ */
function handleOk() { function handleOk() {
formRef.value if (!formData.value.img) return message.error('请上传图片');
.validateFields() formRef.value.validateFields().then(async (values) => {
.then(async (values) => { console.log(values)
try { try {
showLoading() showLoading()
const params = {
const params = { ...values,
...values, img: formData.value.img,
roles: formatArr(rolesValue.value), fullImg: formData.value.fullImg,
} smallImg: formData.value.smallImg,
let result = null videoUrl: formData.value.videoUrl,
switch (modal.value.type) { pushAt:dayjs(formData.value.pushAt).format("YYYY-MM-DD"),
case 'create':
result = await apis.users.createUsers(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
} }
}) let result = null
.catch(() => { console.log(modal.value.type)
switch (modal.value.type) {
case 'create':
result = await apis.videoCenter.createDynamic(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.videoCenter.updateItem(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
console.log(error)
hideLoading()
}
})
.catch((e) => {
console.log(e)
hideLoading() hideLoading()
}) })
} }
@ -273,6 +229,10 @@ function formatArr(data, type = '') {
* 取消 * 取消
*/ */
function handleCancel() { function handleCancel() {
imgUrl.value = ''
fullImg.value = ''
smallImg.value = ''
videoUrl.value = ''
hideModal() hideModal()
} }
@ -288,6 +248,32 @@ defineExpose({
handleCreate, handleCreate,
handleEdit, handleEdit,
}) })
/**
* 视频上传
*/
function beforeUpload(file) {
const isVideo = file.type.startsWith('video/')
const isLt100M = file.size / 1024 / 1024 < 100
if (!isVideo) {
message.error('只能上传视频文件')
return false
}
if (!isLt100M) {
message.error('视频大小不能超过 100MB')
return false
}
return true
}
function handleUploadSuccess(response) {
formData.videoUrl = response.url // { url: 'xxx.mp4' }
message.success('视频上传成功')
videoChange(response.url) // videoChange
}
function videoChange(url) {
console.log('视频改变了:', url)
}
</script> </script>
<style lang="less" scoped></style> <style lang="less" scoped></style>

View File

@ -1,44 +1,28 @@
<template> <template>
<x-search-bar class="mb-8-2"> <x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }"> <template #default="{ gutter, colSpan }">
<a-form <a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
:label-col="{ style: { width: '100px' } }"
:model="searchFormData"
layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item <a-form-item label="标题" name="title">
:label="$t('pages.system.user.form.username')" <a-input placeholder="请输入视频动态标题" v-model:value="searchFormData.title"></a-input>
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="searchFormData.username"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item name="name"> <a-form-item label="状态" name="status">
<template #label> <a-select v-model:value="searchFormData.status" allowClear>
{{ $t('pages.system.user.form.name') }} <a-select-option value="">全部</a-select-option>
<a-tooltip :title="$t('pages.system.user.form.name')"> <a-select-option value="enabled">启用</a-select-option>
<question-circle-outlined class="ml-4-1 color-placeholder" /> <a-select-option value="disabled">停用</a-select-option>
</a-tooltip> </a-select>
</template>
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="searchFormData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col <a-col class="align-right" v-bind="colSpan">
class="align-right"
v-bind="colSpan">
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button <a-button ghost type="primary" @click="handleSearch">
ghost
type="primary"
@click="handleSearch">
{{ $t('button.search') }} {{ $t('button.search') }}
</a-button> </a-button>
</a-space> </a-space>
@ -47,58 +31,58 @@
</a-form> </a-form>
</template> </template>
</x-search-bar> </x-search-bar>
<a-row <a-row :gutter="8" :wrap="false">
:gutter="8"
:wrap="false">
<a-col flex="auto"> <a-col flex="auto">
<a-card type="flex"> <a-card type="flex">
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button <a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
type="primary"
@click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
{{ $t('pages.system.user.add') }} 新增动态
</a-button> </a-button>
</x-action-bar> </x-action-bar>
<a-table <a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:columns="columns" :pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
:data-source="listData"
:loading="loading"
:pagination="paginationState"
:scroll="{ x: 1000 }"
@change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'statusType' === column.key"> <template v-if="'fullImg' === column.dataIndex">
<!--状态--> <a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
<a-tag
v-if="statusUserTypeEnum.is('activated', record.status)"
color="processing">
{{ statusUserTypeEnum.getDesc(record.status) }}
</a-tag>
<!--状态-->
<a-tag
v-if="statusUserTypeEnum.is('freezed', record.status)"
color="processing">
{{ statusUserTypeEnum.getDesc(record.status) }}
</a-tag>
</template> </template>
<template v-if="'smallImg' === column.dataIndex">
<template v-if="'createAt' === column.key"> <a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
{{ formatUtcDateTime(record.created_at) }} </template>
<template v-if="'videoUrl' === column.dataIndex">
<video :width="60" :src="config('http.apiBasic') + record.mp4 || $mp4Err.mp4Err"/>
</template>
<template v-if="column.dataIndex === 'title'">
<a-tooltip :title="record.title">
<span>{{ record.title }}</span>
</a-tooltip>
</template>
<template v-if="column.dataIndex === 'subheading'">
<a-tooltip :title="record.subheading">
<span>{{ record.subheading }}</span>
</a-tooltip>
</template>
<template v-if="column.dataIndex === 'link'">
<a-tooltip :title="record.link">
<a :href="record.link" target="_blank" style="text-decoration: underline;">{{
record.link }}</a>
</a-tooltip>
</template>
<template v-if="'status' === column.dataIndex">
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.user.edit') }}</template> <template #title> {{ $t('pages.system.user.edit') }}</template>
<edit-outlined /> </a-tooltip <edit-outlined /> </a-tooltip></x-action-button>
></x-action-button>
<x-action-button @click="handleDelete(record)"> <x-action-button @click="handleDelete(record)">
<a-tooltip> <a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template> <template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip <delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
></x-action-button>
</template> </template>
</template> </template>
</a-table> </a-table>
@ -106,9 +90,7 @@
</a-col> </a-col>
</a-row> </a-row>
<edit-dialog <edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
ref="editDialogRef"
@ok="onOk"></edit-dialog>
</template> </template>
<script setup> <script setup>
@ -128,13 +110,15 @@ defineOptions({
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
const columns = [ const columns = [
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 }, { title: '大图片', dataIndex: 'fullImg', width: 100, align: 'center' },
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 }, { title: '小图片', dataIndex: 'smallImg', width: 100, align: 'center' },
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 }, { title: '视频', dataIndex: 'videoUrl', width: 100, align: 'center' },
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 }, { title: '标题', dataIndex: 'title', key: 'title' },
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 }, { title: '简介', dataIndex: 'subheading', key: 'subheading' },
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 }, { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 }, { title: '发布日期', dataIndex: 'pushAt', width: 120, align: 'center' },
{ title: '链接', dataIndex: 'link', align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
] ]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
@ -150,8 +134,8 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { success, data, total } = await apis.users const { success, data, total } = await apis.videoCenter
.getUsersList({ .getDataList({
pageSize, pageSize,
page: current, page: current,
...searchFormData.value, ...searchFormData.value,
@ -179,9 +163,9 @@ function handleDelete({ id }) {
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
;(async () => { ; (async () => {
try { try {
const { success } = await apis.users.delUsers(id).catch(() => { const { success } = await apis.videoCenter.delItem(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {

View File

@ -1,112 +1,45 @@
<template> <template>
<a-modal <a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
:open="modal.open" :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
:title="modal.title" <a-form ref="formRef" :model="formData" :rules="formRules">
:width="640"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ style: { width: '90px' } }">
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="12"> <a-row :gutter="16">
<a-form-item <a-col :span="12">
:label="$t('pages.system.user.form.username')" <a-form-item label="年份" name="year">
name="username"> <a-select v-model:value="formData.year" placeholder="请选择年份">
<a-input <a-select-option v-for="y in yearOptions" :key="y" :value="y">{{ y }}</a-select-option>
:placeholder="$t('pages.system.user.form.username.placeholder')" </a-select>
v-model:value="formData.username"></a-input> </a-form-item>
</a-form-item> </a-col>
</a-col> <a-col :span="12">
<a-col :span="12"> <a-form-item label="月份" name="month">
<a-form-item <a-select v-model:value="formData.month" placeholder="请选择月份">
:label="$t('pages.system.user.form.password')" <!-- <a-select-option v-for="m in 12" :key="m" :value="m.toString().padStart(2, '0')">-->
name="password"> <a-select-option v-for="m in 12" :key="m">
<a-input-password {{ m }}
v-model:value="formData.password" </a-select-option>
:placeholder="$t('pages.system.user.form.password.placeholder')" /> </a-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.name')"
name="name">
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="formData.name"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.roles')"
name="roles">
<a-select
v-model:value="formData.roles"
mode="multiple"
style="width: 100%"
:placeholder="$t('pages.system.user.form.roles.placeholder')"
:options="roles"
@change="handleChange"></a-select>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.phone')"
type="tel"
name="phone">
<a-input
:placeholder="$t('pages.system.user.form.phone.placeholder')"
type="tel"
v-model:value="formData.phone"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.email')"
type="email"
name="email">
<a-input
:placeholder="$t('pages.system.user.form.email.placeholder')"
type="email"
v-model:value="formData.email"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'事件'" name="title">
:label="$t('pages.system.user.form.remark')" <a-input :placeholder="'请输入名称'" v-model:value="formData.title"></a-input>
name="remark">
<a-textarea
:placeholder="$t('pages.system.user.form.remark.placeholder')"
v-model:value="formData.remark"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'顺序'" name="sequence">
:label="$t('pages.system.user.form.status')" <a-input-number :placeholder="'请输入顺序'" v-model:value="formData.sequence"></a-input-number>
name="status"> </a-form-item>
<a-radio-group </a-col>
v-model:value="formData.status" <a-col :span="24">
:options="[ <a-form-item :label="'状态'" name="status">
{ label: $t('pages.system.user.form.status.activated'), value: 'activated' }, <a-radio-group v-model:value="formData.status" :options="[
{ label: $t('pages.system.user.form.status.freezed'), value: 'freezed' }, { label: '启用', value: 'enabled' },
]"></a-radio-group> { label: '停用', value: 'disabled' },
]"></a-radio-group>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -123,6 +56,8 @@ import apis from '@/apis'
import { useForm, useModal } from '@/hooks' import { useForm, useModal } from '@/hooks'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
import { createMenu, getMenu, updateMenu } from '@/apis/modules/imgmgt'
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
const { t } = useI18n() // t const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
@ -131,18 +66,22 @@ const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm')) const okText = ref(t('button.confirm'))
const rolesValue = ref([]) const rolesValue = ref([])
const roles = ref([]) const roles = ref([])
const img = ref('')
formRules.value = { formRules.value = {
name: { required: true, message: t('pages.system.user.form.username.placeholder') }, title: { required: true, message: '请输入事件' },
username: { required: true, message: t('pages.system.user.form.code.placeholder') }, year: { required: true, message: '请输入年份' },
status: { required: true, message: t('pages.system.user.form.status') }, month: { required: true, message: '请输入月份' },
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }], status: [{ required: true, message: '请选择状态', trigger: 'change' }],
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
} }
/** /**
* 请求角色 * select 年月
*/ */
getRole() const yearOptions = [];
const currentYear = new Date().getFullYear();
for (let i = currentYear - 20; i <= currentYear + 20; i++) {
yearOptions.push(i);
}
/** /**
* select 选择框 * select 选择框
@ -150,94 +89,80 @@ getRole()
const handleChange = (value) => { const handleChange = (value) => {
rolesValue.value = value rolesValue.value = value
} }
const imgChange = (value) => {
formData.value.img = value
}
/** /**
* 新建 * 新建
*/ */
function handleCreate() { function handleCreate() {
showModal({ showModal({
type: 'create', type: 'create',
title: t('pages.system.user.add'), title: '添加公司动态',
}) })
formData.value.status = 'enabled'
} }
async function getRole() {
const { success, data } = await apis.role.getRoleList().catch(() => {
throw new Error()
})
if (!success) {
return message.error('当前角色信息错误')
}
let roleArr = []
if (data.length) {
data.forEach((item) => {
roleArr.push({
label: item.name,
value: item.id,
})
})
}
roles.value = roleArr
}
/** /**
* 编辑 * 编辑
*/ */
async function handleEdit(record = {}) { async function handleEdit(record = {}) {
showModal({ showModal({
type: 'edit', type: 'edit',
// 80about
title: t('pages.system.user.edit'), title: t('pages.system.user.edit'),
}) })
const { data, success } = await apis.users.getUsers(record.id).catch() const { data, success } = await apis.importantEvents.getMenu(record.id).catch()
if (!success) { if (!success) {
hideModal() hideModal()
return return
} }
let roles = [] formData.value = { ...data }
if (data.roles) { formData.value.pushAt=dayjs(data.pushAt)
roles = formatArr(data.roles, 'edit') console.log(formData.value)
} img.value = config('http.apiBasic') + data.img
data.roles = roles
formRecord.value = data
formData.value = cloneDeep(data)
} }
/** /**
* 确定 * 确定
*/ */
function handleOk() { function handleOk() {
formRef.value
.validateFields()
.then(async (values) => {
try {
showLoading()
const params = { formRef.value.validateFields().then(async (values) => {
...values, console.log(values)
roles: formatArr(rolesValue.value), try {
} showLoading()
let result = null const params = {
switch (modal.value.type) { ...values,
case 'create': // pushAt:dayjs(formData.value.pushAt).format("YYYY-MM-DD"),
result = await apis.users.createUsers(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
} }
}) let result = null
.catch(() => { console.log(modal.value.type)
switch (modal.value.type) {
case 'create':
result = await apis.importantEvents.createMenu(params).catch(() => {
throw new Error()
})
break
case 'edit':
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
result = await apis.importantEvents.updateMenu(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
console.log(error)
hideLoading()
}
})
.catch((e) => {
console.log(e)
hideLoading() hideLoading()
}) })
} }
@ -273,6 +198,7 @@ function formatArr(data, type = '') {
* 取消 * 取消
*/ */
function handleCancel() { function handleCancel() {
img.value = ''
hideModal() hideModal()
} }

View File

@ -1,44 +1,28 @@
<template> <template>
<x-search-bar class="mb-8-2"> <x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }"> <template #default="{ gutter, colSpan }">
<a-form <a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
:label-col="{ style: { width: '100px' } }"
:model="searchFormData"
layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item <a-form-item label="事件" name="title">
:label="$t('pages.system.user.form.username')" <a-input placeholder="请输入事件名称" v-model:value="searchFormData.title"></a-input>
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="searchFormData.username"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item name="name"> <a-form-item label="状态" name="status">
<template #label> <a-select v-model:value="searchFormData.status" allowClear>
{{ $t('pages.system.user.form.name') }} <a-select-option value="">全部</a-select-option>
<a-tooltip :title="$t('pages.system.user.form.name')"> <a-select-option value="enabled">启用</a-select-option>
<question-circle-outlined class="ml-4-1 color-placeholder" /> <a-select-option value="disabled">停用</a-select-option>
</a-tooltip> </a-select>
</template>
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="searchFormData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col <a-col class="align-right" v-bind="colSpan">
class="align-right"
v-bind="colSpan">
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button <a-button ghost type="primary" @click="handleSearch">
ghost
type="primary"
@click="handleSearch">
{{ $t('button.search') }} {{ $t('button.search') }}
</a-button> </a-button>
</a-space> </a-space>
@ -47,58 +31,42 @@
</a-form> </a-form>
</template> </template>
</x-search-bar> </x-search-bar>
<a-row <a-row :gutter="8" :wrap="false">
:gutter="8"
:wrap="false">
<a-col flex="auto"> <a-col flex="auto">
<a-card type="flex"> <a-card type="flex">
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button <a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
type="primary"
@click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
{{ $t('pages.system.user.add') }} 新增动态
</a-button> </a-button>
</x-action-bar> </x-action-bar>
<a-table <a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:columns="columns" :pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
:data-source="listData"
:loading="loading"
:pagination="paginationState"
:scroll="{ x: 1000 }"
@change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'statusType' === column.key"> <!-- <template v-if="'img' === column.dataIndex">-->
<!--状态--> <!-- <a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />-->
<a-tag <!-- </template>-->
v-if="statusUserTypeEnum.is('activated', record.status)" <template v-if="column.dataIndex === 'name'">
color="processing"> <a-tooltip :title="record.name">
{{ statusUserTypeEnum.getDesc(record.status) }} <span>{{ record.name }}</span>
</a-tag> </a-tooltip>
<!--状态-->
<a-tag
v-if="statusUserTypeEnum.is('freezed', record.status)"
color="processing">
{{ statusUserTypeEnum.getDesc(record.status) }}
</a-tag>
</template> </template>
<template v-if="'createAt' === column.key"> <template v-if="'status' === column.dataIndex">
{{ formatUtcDateTime(record.created_at) }} <a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.user.edit') }}</template> <template #title> {{ $t('pages.system.user.edit') }}</template>
<edit-outlined /> </a-tooltip <edit-outlined /> </a-tooltip></x-action-button>
></x-action-button>
<x-action-button @click="handleDelete(record)"> <x-action-button @click="handleDelete(record)">
<a-tooltip> <a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template> <template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip <delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
></x-action-button>
</template> </template>
</template> </template>
</a-table> </a-table>
@ -106,9 +74,7 @@
</a-col> </a-col>
</a-row> </a-row>
<edit-dialog <edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
ref="editDialogRef"
@ok="onOk"></edit-dialog>
</template> </template>
<script setup> <script setup>
@ -123,18 +89,18 @@ import { usePagination } from '@/hooks'
import EditDialog from './components/EditDialog.vue' import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { delMenu, getDataList } from '@/apis/modules/imgmgt'
defineOptions({ defineOptions({
name: 'importantEvents', name: 'importantEvents',
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
const columns = [ const columns = [
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 }, { title: '年份', dataIndex: 'year', width: 100, align: 'center' },
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 }, { title: '月份', dataIndex: 'month', key: 'month' },
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 }, { title: '事件', dataIndex: 'title', key: 'title' },
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 }, { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 }, { title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 }, { title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 },
] ]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
@ -150,8 +116,8 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { success, data, total } = await apis.users const { success, data, total } = await apis.importantEvents
.getUsersList({ .getDataList({
pageSize, pageSize,
page: current, page: current,
...searchFormData.value, ...searchFormData.value,
@ -161,6 +127,7 @@ async function getPageList() {
}) })
hideLoading() hideLoading()
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
//type80about
listData.value = data listData.value = data
paginationState.total = total paginationState.total = total
} }
@ -179,9 +146,9 @@ function handleDelete({ id }) {
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
;(async () => { ; (async () => {
try { try {
const { success } = await apis.users.delUsers(id).catch(() => { const { success } = await apis.importantEvents.delMenu(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {

View File

@ -1,112 +1,41 @@
<template> <template>
<a-modal <a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
:open="modal.open" :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
:title="modal.title" <a-form ref="formRef" :model="formData" :rules="formRules">
:width="640"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ style: { width: '90px' } }">
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.username')"
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="formData.username"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.password')"
name="password">
<a-input-password
v-model:value="formData.password"
:placeholder="$t('pages.system.user.form.password.placeholder')" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.name')"
name="name">
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="formData.name"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.roles')"
name="roles">
<a-select
v-model:value="formData.roles"
mode="multiple"
style="width: 100%"
:placeholder="$t('pages.system.user.form.roles.placeholder')"
:options="roles"
@change="handleChange"></a-select>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.phone')"
type="tel"
name="phone">
<a-input
:placeholder="$t('pages.system.user.form.phone.placeholder')"
type="tel"
v-model:value="formData.phone"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.email')"
type="email"
name="email">
<a-input
:placeholder="$t('pages.system.user.form.email.placeholder')"
type="email"
v-model:value="formData.email"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'姓名'" name="name">
:label="$t('pages.system.user.form.remark')" <a-input :placeholder="'请输入姓名'" v-model:value="formData.name"></a-input>
name="remark">
<a-textarea
:placeholder="$t('pages.system.user.form.remark.placeholder')"
v-model:value="formData.remark"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'人物描述'" name="rank">
:label="$t('pages.system.user.form.status')" <a-input :placeholder="'请输入人物描述内容'" v-model:value="formData.rank"></a-input>
name="status"> </a-form-item>
<a-radio-group </a-col>
v-model:value="formData.status" <a-col :span="24">
:options="[ <a-form-item :label="'研究领域'" name="area">
{ label: $t('pages.system.user.form.status.activated'), value: 'activated' }, <a-input :placeholder="'请输入研究领域内容'" v-model:value="formData.area"></a-input>
{ label: $t('pages.system.user.form.status.freezed'), value: 'freezed' }, </a-form-item>
]"></a-radio-group> </a-col>
<a-col :span="24">
<a-form-item :label="'顺序'" name="sequence">
<a-input-number :placeholder="'请输入顺序'" v-model:value="formData.sequence"></a-input-number>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'状态'" name="status">
<a-radio-group v-model:value="formData.status" :options="[
{ label: '启用', value: 'enabled' },
{ label: '停用', value: 'disabled' },
]"></a-radio-group>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'图片'" name="img">
<x-upload-image v-model="img" @imgChange="imgChange" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -123,6 +52,8 @@ import apis from '@/apis'
import { useForm, useModal } from '@/hooks' import { useForm, useModal } from '@/hooks'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
import { createMenu, getMenu, updateMenu } from '@/apis/modules/imgmgt'
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
const { t } = useI18n() // t const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
@ -131,113 +62,101 @@ const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm')) const okText = ref(t('button.confirm'))
const rolesValue = ref([]) const rolesValue = ref([])
const roles = ref([]) const roles = ref([])
const img = ref('')
formRules.value = { formRules.value = {
name: { required: true, message: t('pages.system.user.form.username.placeholder') }, name: { required: true, message: '请输入名称' },
username: { required: true, message: t('pages.system.user.form.code.placeholder') }, status: [{ required: true, message: '请选择状态', trigger: 'change' }],
status: { required: true, message: t('pages.system.user.form.status') }, sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }], img: [{ required: true, message: '请上传图片', trigger: 'change' }],
} }
/**
* 请求角色
*/
getRole()
/** /**
* select 选择框 * select 选择框
*/ */
const handleChange = (value) => { const handleChange = (value) => {
rolesValue.value = value rolesValue.value = value
} }
const imgChange = (value) => {
formData.value.img = value
}
/** /**
* 新建 * 新建
*/ */
function handleCreate() { function handleCreate() {
showModal({ showModal({
type: 'create', type: 'create',
title: t('pages.system.user.add'), // 80about
title: '添加公司动态',
}) })
formData.value.status = 'enabled'
} }
async function getRole() {
const { success, data } = await apis.role.getRoleList().catch(() => {
throw new Error()
})
if (!success) {
return message.error('当前角色信息错误')
}
let roleArr = []
if (data.length) {
data.forEach((item) => {
roleArr.push({
label: item.name,
value: item.id,
})
})
}
roles.value = roleArr
}
/** /**
* 编辑 * 编辑
*/ */
async function handleEdit(record = {}) { async function handleEdit(record = {}) {
showModal({ showModal({
type: 'edit', type: 'edit',
// 80about
title: t('pages.system.user.edit'), title: t('pages.system.user.edit'),
}) })
const { data, success } = await apis.users.getUsers(record.id).catch() const { data, success } = await apis.team.getMenu(record.id).catch()
if (!success) { if (!success) {
hideModal() hideModal()
return return
} }
let roles = [] formData.value = { ...data }
if (data.roles) { formData.value.pushAt=dayjs(data.pushAt)
roles = formatArr(data.roles, 'edit') console.log(formData.value)
} img.value = config('http.apiBasic') + data.img
data.roles = roles
formRecord.value = data
formData.value = cloneDeep(data)
} }
/** /**
* 确定 * 确定
*/ */
function handleOk() { function handleOk() {
formRef.value if (!formData.value.img) return message.error('请上传图片');
.validateFields() formRef.value.validateFields().then(async (values) => {
.then(async (values) => { console.log(values)
try { try {
showLoading() showLoading()
const params = {
const params = { ...values,
...values, rank: Array.isArray(formData.rank)
roles: formatArr(rolesValue.value), ? formData.rank
} : typeof formData.rank === 'string'
let result = null ? formData.rank
switch (modal.value.type) { .split(/[\s;]+/)
case 'create': .map(item => item.trim())
result = await apis.users.createUsers(params).catch(() => { .filter(Boolean)
throw new Error() : [],
}) img: formData.value.img,
break
case 'edit':
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
} }
}) let result = null
.catch(() => { console.log(modal.value.type)
switch (modal.value.type) {
case 'create':
result = await apis.team.createMenu(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.team.updateMenu(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
console.log(error)
hideLoading()
}
})
.catch((e) => {
console.log(e)
hideLoading() hideLoading()
}) })
} }
@ -273,6 +192,7 @@ function formatArr(data, type = '') {
* 取消 * 取消
*/ */
function handleCancel() { function handleCancel() {
img.value = ''
hideModal() hideModal()
} }

View File

@ -1,44 +1,28 @@
<template> <template>
<x-search-bar class="mb-8-2"> <x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }"> <template #default="{ gutter, colSpan }">
<a-form <a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
:label-col="{ style: { width: '100px' } }"
:model="searchFormData"
layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item <a-form-item label="成员" name="name">
:label="$t('pages.system.user.form.username')" <a-input placeholder="请输入成员" v-model:value="searchFormData.name"></a-input>
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="searchFormData.username"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item name="name"> <a-form-item label="状态" name="status">
<template #label> <a-select v-model:value="searchFormData.status" allowClear>
{{ $t('pages.system.user.form.name') }} <a-select-option value="">全部</a-select-option>
<a-tooltip :title="$t('pages.system.user.form.name')"> <a-select-option value="enabled">启用</a-select-option>
<question-circle-outlined class="ml-4-1 color-placeholder" /> <a-select-option value="disabled">停用</a-select-option>
</a-tooltip> </a-select>
</template>
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="searchFormData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col <a-col class="align-right" v-bind="colSpan">
class="align-right"
v-bind="colSpan">
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button <a-button ghost type="primary" @click="handleSearch">
ghost
type="primary"
@click="handleSearch">
{{ $t('button.search') }} {{ $t('button.search') }}
</a-button> </a-button>
</a-space> </a-space>
@ -47,58 +31,55 @@
</a-form> </a-form>
</template> </template>
</x-search-bar> </x-search-bar>
<a-row <a-row :gutter="8" :wrap="false">
:gutter="8"
:wrap="false">
<a-col flex="auto"> <a-col flex="auto">
<a-card type="flex"> <a-card type="flex">
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button <a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
type="primary"
@click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
{{ $t('pages.system.user.add') }} 新增动态
</a-button> </a-button>
</x-action-bar> </x-action-bar>
<a-table <a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:columns="columns" :pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
:data-source="listData"
:loading="loading"
:pagination="paginationState"
:scroll="{ x: 1000 }"
@change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'statusType' === column.key"> <template v-if="'img' === column.dataIndex">
<!--状态--> <!-- <a-image :width="60" :src="record.img || $imageErr.imgErr" />-->
<a-tag <a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
v-if="statusUserTypeEnum.is('activated', record.status)" </template>
color="processing"> <template v-if="column.dataIndex === 'name'">
{{ statusUserTypeEnum.getDesc(record.status) }} <a-tooltip :title="record.name">
</a-tag> <span>{{ record.name }}</span>
<!--状态--> </a-tooltip>
<a-tag
v-if="statusUserTypeEnum.is('freezed', record.status)"
color="processing">
{{ statusUserTypeEnum.getDesc(record.status) }}
</a-tag>
</template> </template>
<template v-if="'createAt' === column.key"> <template v-if="column.dataIndex === 'rank'">
{{ formatUtcDateTime(record.created_at) }} <a-tooltip :title="record.rank">
<span>{{ record.rank }}</span>
</a-tooltip>
</template>
<template v-if="column.dataIndex === 'area'">
<a-tooltip :title="record.area">
<span>{{ record.area }}</span>
</a-tooltip>
</template>
<template v-if="'status' === column.dataIndex">
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.user.edit') }}</template> <template #title> {{ $t('pages.system.user.edit') }}</template>
<edit-outlined /> </a-tooltip <edit-outlined /> </a-tooltip></x-action-button>
></x-action-button>
<x-action-button @click="handleDelete(record)"> <x-action-button @click="handleDelete(record)">
<a-tooltip> <a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template> <template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip <delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
></x-action-button>
</template> </template>
</template> </template>
</a-table> </a-table>
@ -106,9 +87,7 @@
</a-col> </a-col>
</a-row> </a-row>
<edit-dialog <edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
ref="editDialogRef"
@ok="onOk"></edit-dialog>
</template> </template>
<script setup> <script setup>
@ -123,18 +102,19 @@ import { usePagination } from '@/hooks'
import EditDialog from './components/EditDialog.vue' import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { delMenu, getDataList } from '@/apis/modules/imgmgt'
defineOptions({ defineOptions({
name: 'team', name: 'team',
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
const columns = [ const columns = [
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 }, { title: '图片', dataIndex: 'img', width: 100, align: 'center' },
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 }, { title: '名称', dataIndex: 'name', key: 'name' },
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 }, { title: '任务描述', dataIndex: 'rank', key: 'rank' },
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 }, { title: '研究领域', dataIndex: 'area', key: 'area' },
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 }, { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 }, { title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 }, { title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
] ]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
@ -150,8 +130,8 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { success, data, total } = await apis.users const { success, data, total } = await apis.team
.getUsersList({ .getDataList({
pageSize, pageSize,
page: current, page: current,
...searchFormData.value, ...searchFormData.value,
@ -179,9 +159,9 @@ function handleDelete({ id }) {
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
;(async () => { ; (async () => {
try { try {
const { success } = await apis.users.delUsers(id).catch(() => { const { success } = await apis.team.delMenu(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {

View File

@ -1,44 +1,28 @@
<template> <template>
<x-search-bar class="mb-8-2"> <x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }"> <template #default="{ gutter, colSpan }">
<a-form <a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
:label-col="{ style: { width: '100px' } }"
:model="searchFormData"
layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item <a-form-item label="名称" name="name">
:label="$t('pages.system.user.form.username')" <a-input placeholder="请输入图片名称" v-model:value="searchFormData.name"></a-input>
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="searchFormData.username"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item name="name"> <a-form-item label="状态" name="status">
<template #label> <a-select v-model:value="searchFormData.status" allowClear>
{{ $t('pages.system.user.form.name') }} <a-select-option value="">全部</a-select-option>
<a-tooltip :title="$t('pages.system.user.form.name')"> <a-select-option value="enabled">启用</a-select-option>
<question-circle-outlined class="ml-4-1 color-placeholder" /> <a-select-option value="disabled">停用</a-select-option>
</a-tooltip> </a-select>
</template>
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="searchFormData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col <a-col class="align-right" v-bind="colSpan">
class="align-right"
v-bind="colSpan">
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button <a-button ghost type="primary" @click="handleSearch">
ghost
type="primary"
@click="handleSearch">
{{ $t('button.search') }} {{ $t('button.search') }}
</a-button> </a-button>
</a-space> </a-space>
@ -47,58 +31,48 @@
</a-form> </a-form>
</template> </template>
</x-search-bar> </x-search-bar>
<a-row <a-row :gutter="8" :wrap="false">
:gutter="8"
:wrap="false">
<a-col flex="auto"> <a-col flex="auto">
<a-card type="flex"> <a-card type="flex">
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button <a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
type="primary"
@click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
{{ $t('pages.system.user.add') }} 新增动态
</a-button> </a-button>
</x-action-bar> </x-action-bar>
<a-table <a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:columns="columns" :pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
:data-source="listData"
:loading="loading"
:pagination="paginationState"
:scroll="{ x: 1000 }"
@change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'statusType' === column.key"> <template v-if="'img' === column.dataIndex">
<!--状态--> <!-- <a-image :width="60" :src="record.img || $imageErr.imgErr" />-->
<a-tag <a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
v-if="statusUserTypeEnum.is('activated', record.status)" </template>
color="processing"> <template v-if="column.dataIndex === 'name'">
{{ statusUserTypeEnum.getDesc(record.status) }} <a-tooltip :title="record.name">
</a-tag> <span>{{ record.name }}</span>
<!--状态--> </a-tooltip>
<a-tag </template>
v-if="statusUserTypeEnum.is('freezed', record.status)" <template v-if="column.dataIndex === 'link'">
color="processing"> <a-tooltip :title="record.link">
{{ statusUserTypeEnum.getDesc(record.status) }} <span>{{ record.link }}</span>
</a-tag> </a-tooltip>
</template> </template>
<template v-if="'createAt' === column.key"> <template v-if="'status' === column.dataIndex">
{{ formatUtcDateTime(record.created_at) }} <a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.user.edit') }}</template> <template #title> {{ $t('pages.system.user.edit') }}</template>
<edit-outlined /> </a-tooltip <edit-outlined /> </a-tooltip></x-action-button>
></x-action-button>
<x-action-button @click="handleDelete(record)"> <x-action-button @click="handleDelete(record)">
<a-tooltip> <a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template> <template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip <delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
></x-action-button>
</template> </template>
</template> </template>
</a-table> </a-table>
@ -106,9 +80,7 @@
</a-col> </a-col>
</a-row> </a-row>
<edit-dialog <edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
ref="editDialogRef"
@ok="onOk"></edit-dialog>
</template> </template>
<script setup> <script setup>
@ -123,18 +95,18 @@ import { usePagination } from '@/hooks'
import EditDialog from './components/EditDialog.vue' import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { delMenu, getDataList } from '@/apis/modules/imgmgt'
defineOptions({ defineOptions({
name: 'contactUs', name: 'contactUs',
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
const columns = [ const columns = [
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 }, { title: '图片', dataIndex: 'img', width: 100, align: 'center' },
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 }, { title: '名称', dataIndex: 'name', key: 'name' },
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 }, { title: '链接', dataIndex: 'link', key: 'link' },
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 }, { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 }, { title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 }, { title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 },
] ]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
@ -150,8 +122,8 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { success, data, total } = await apis.users const { success, data, total } = await apis.imgmgt
.getUsersList({ .getDataList({
pageSize, pageSize,
page: current, page: current,
...searchFormData.value, ...searchFormData.value,
@ -161,7 +133,8 @@ async function getPageList() {
}) })
hideLoading() hideLoading()
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
listData.value = data //type10friendlyLinks
listData.value = data.filter(item => item.type===10)
paginationState.total = total paginationState.total = total
} }
} catch (error) { } catch (error) {
@ -179,9 +152,9 @@ function handleDelete({ id }) {
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
;(async () => { ; (async () => {
try { try {
const { success } = await apis.users.delUsers(id).catch(() => { const { success } = await apis.imgmgt.delMenu(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {

View File

@ -1,112 +1,35 @@
<template> <template>
<a-modal <a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
:open="modal.open" :after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
:title="modal.title" <a-form ref="formRef" :model="formData" :rules="formRules">
:width="640"
:confirm-loading="modal.confirmLoading"
:after-close="onAfterClose"
:cancel-text="cancelText"
:ok-text="okText"
@ok="handleOk"
@cancel="handleCancel">
<a-form
ref="formRef"
:model="formData"
:rules="formRules"
:label-col="{ style: { width: '90px' } }">
<a-card class="mb-8-2"> <a-card class="mb-8-2">
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.username')"
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="formData.username"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.password')"
name="password">
<a-input-password
v-model:value="formData.password"
:placeholder="$t('pages.system.user.form.password.placeholder')" />
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.name')"
name="name">
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="formData.name"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.roles')"
name="roles">
<a-select
v-model:value="formData.roles"
mode="multiple"
style="width: 100%"
:placeholder="$t('pages.system.user.form.roles.placeholder')"
:options="roles"
@change="handleChange"></a-select>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.phone')"
type="tel"
name="phone">
<a-input
:placeholder="$t('pages.system.user.form.phone.placeholder')"
type="tel"
v-model:value="formData.phone"></a-input>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item
:label="$t('pages.system.user.form.email')"
type="email"
name="email">
<a-input
:placeholder="$t('pages.system.user.form.email.placeholder')"
type="email"
v-model:value="formData.email"></a-input>
</a-form-item>
</a-col>
</a-row>
<a-row :gutter="12"> <a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'名称'" name="name">
:label="$t('pages.system.user.form.remark')" <a-input :placeholder="'请输入名称'" v-model:value="formData.name"></a-input>
name="remark">
<a-textarea
:placeholder="$t('pages.system.user.form.remark.placeholder')"
v-model:value="formData.remark"></a-textarea>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row>
<a-row :gutter="12">
<a-col :span="24"> <a-col :span="24">
<a-form-item <a-form-item :label="'链接'" name="link">
:label="$t('pages.system.user.form.status')" <a-input :placeholder="'请输入链接'" v-model:value="formData.link"></a-input>
name="status"> </a-form-item>
<a-radio-group </a-col>
v-model:value="formData.status" <a-col :span="24">
:options="[ <a-form-item :label="'顺序'" name="sequence">
{ label: $t('pages.system.user.form.status.activated'), value: 'activated' }, <a-input-number :placeholder="'请输入顺序'" v-model:value="formData.sequence"></a-input-number>
{ label: $t('pages.system.user.form.status.freezed'), value: 'freezed' }, </a-form-item>
]"></a-radio-group> </a-col>
<a-col :span="24">
<a-form-item :label="'状态'" name="status">
<a-radio-group v-model:value="formData.status" :options="[
{ label: '启用', value: 'enabled' },
{ label: '停用', value: 'disabled' },
]"></a-radio-group>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item :label="'图片'" name="img">
<x-upload-image v-model="img" @imgChange="imgChange" />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -123,6 +46,8 @@ import apis from '@/apis'
import { useForm, useModal } from '@/hooks' import { useForm, useModal } from '@/hooks'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
import { createMenu, getMenu, updateMenu } from '@/apis/modules/imgmgt'
const emit = defineEmits(['ok']) const emit = defineEmits(['ok'])
const { t } = useI18n() // t const { t } = useI18n() // t
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal() const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
@ -131,53 +56,34 @@ const cancelText = ref(t('button.cancel'))
const okText = ref(t('button.confirm')) const okText = ref(t('button.confirm'))
const rolesValue = ref([]) const rolesValue = ref([])
const roles = ref([]) const roles = ref([])
const img = ref('')
formRules.value = { formRules.value = {
name: { required: true, message: t('pages.system.user.form.username.placeholder') }, name: { required: true, message: '请输入名称' },
username: { required: true, message: t('pages.system.user.form.code.placeholder') }, status: [{ required: true, message: '请选择状态', trigger: 'change' }],
status: { required: true, message: t('pages.system.user.form.status') }, sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }], img: [{ required: true, message: '请上传图片', trigger: 'change' }],
} }
/**
* 请求角色
*/
getRole()
/** /**
* select 选择框 * select 选择框
*/ */
const handleChange = (value) => { const handleChange = (value) => {
rolesValue.value = value rolesValue.value = value
} }
const imgChange = (value) => {
formData.value.img = value
}
/** /**
* 新建 * 新建
*/ */
function handleCreate() { function handleCreate() {
showModal({ showModal({
type: 'create', type: 'create',
title: t('pages.system.user.add'), // 80about
title: '添加公司动态',
}) })
formData.value.status = 'enabled'
} }
async function getRole() {
const { success, data } = await apis.role.getRoleList().catch(() => {
throw new Error()
})
if (!success) {
return message.error('当前角色信息错误')
}
let roleArr = []
if (data.length) {
data.forEach((item) => {
roleArr.push({
label: item.name,
value: item.id,
})
})
}
roles.value = roleArr
}
/** /**
* 编辑 * 编辑
*/ */
@ -186,58 +92,60 @@ async function handleEdit(record = {}) {
type: 'edit', type: 'edit',
title: t('pages.system.user.edit'), title: t('pages.system.user.edit'),
}) })
const { data, success } = await apis.users.getUsers(record.id).catch() const { data, success } = await apis.imgmgt.getMenu(record.id).catch()
if (!success) { if (!success) {
hideModal() hideModal()
return return
} }
let roles = [] formData.value = { ...data }
if (data.roles) { formData.value.pushAt=dayjs(data.pushAt)
roles = formatArr(data.roles, 'edit') console.log(formData.value)
} img.value = config('http.apiBasic') + data.img
data.roles = roles
formRecord.value = data
formData.value = cloneDeep(data)
} }
/** /**
* 确定 * 确定
*/ */
function handleOk() { function handleOk() {
formRef.value if (!formData.value.img) return message.error('请上传图片');
.validateFields() formRef.value.validateFields().then(async (values) => {
.then(async (values) => { console.log(values)
try { try {
showLoading() showLoading()
const params = {
const params = { ...values,
...values, img: formData.value.img,
roles: formatArr(rolesValue.value), // pushAt:dayjs(formData.value.pushAt).format("YYYY-MM-DD"),
} type: 10 ,
let result = null // 10friendlyLinks
switch (modal.value.type) {
case 'create':
result = await apis.users.createUsers(params).catch(() => {
throw new Error()
})
break
case 'edit':
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
hideLoading()
} }
}) let result = null
.catch(() => { console.log(modal.value.type)
switch (modal.value.type) {
case 'create':
result = await apis.imgmgt.createMenu(params).catch(() => {
throw new Error()
})
break
case 'edit':
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
throw new Error()
})
break
}
hideLoading()
if (config('http.code.success') === result?.success) {
hideModal()
emit('ok')
}
} catch (error) {
console.log(error)
hideLoading()
}
})
.catch((e) => {
console.log(e)
hideLoading() hideLoading()
}) })
} }
@ -273,6 +181,7 @@ function formatArr(data, type = '') {
* 取消 * 取消
*/ */
function handleCancel() { function handleCancel() {
img.value = ''
hideModal() hideModal()
} }

View File

@ -1,44 +1,28 @@
<template> <template>
<x-search-bar class="mb-8-2"> <x-search-bar class="mb-8-2">
<template #default="{ gutter, colSpan }"> <template #default="{ gutter, colSpan }">
<a-form <a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
:label-col="{ style: { width: '100px' } }"
:model="searchFormData"
layout="inline">
<a-row :gutter="gutter"> <a-row :gutter="gutter">
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item <a-form-item label="名称" name="name">
:label="$t('pages.system.user.form.username')" <a-input placeholder="请输入图片名称" v-model:value="searchFormData.name"></a-input>
name="username">
<a-input
:placeholder="$t('pages.system.user.form.username.placeholder')"
v-model:value="searchFormData.username"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col v-bind="colSpan"> <a-col v-bind="colSpan">
<a-form-item name="name"> <a-form-item label="状态" name="status">
<template #label> <a-select v-model:value="searchFormData.status" allowClear>
{{ $t('pages.system.user.form.name') }} <a-select-option value="">全部</a-select-option>
<a-tooltip :title="$t('pages.system.user.form.name')"> <a-select-option value="enabled">启用</a-select-option>
<question-circle-outlined class="ml-4-1 color-placeholder" /> <a-select-option value="disabled">停用</a-select-option>
</a-tooltip> </a-select>
</template>
<a-input
:placeholder="$t('pages.system.user.form.name.placeholder')"
v-model:value="searchFormData.name"></a-input>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col <a-col class="align-right" v-bind="colSpan">
class="align-right"
v-bind="colSpan">
<a-space> <a-space>
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button> <a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
<a-button <a-button ghost type="primary" @click="handleSearch">
ghost
type="primary"
@click="handleSearch">
{{ $t('button.search') }} {{ $t('button.search') }}
</a-button> </a-button>
</a-space> </a-space>
@ -47,58 +31,48 @@
</a-form> </a-form>
</template> </template>
</x-search-bar> </x-search-bar>
<a-row <a-row :gutter="8" :wrap="false">
:gutter="8"
:wrap="false">
<a-col flex="auto"> <a-col flex="auto">
<a-card type="flex"> <a-card type="flex">
<x-action-bar class="mb-8-2"> <x-action-bar class="mb-8-2">
<a-button <a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
type="primary"
@click="$refs.editDialogRef.handleCreate()">
<template #icon> <template #icon>
<plus-outlined></plus-outlined> <plus-outlined></plus-outlined>
</template> </template>
{{ $t('pages.system.user.add') }} 新增动态
</a-button> </a-button>
</x-action-bar> </x-action-bar>
<a-table <a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
:columns="columns" :pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
:data-source="listData"
:loading="loading"
:pagination="paginationState"
:scroll="{ x: 1000 }"
@change="onTableChange">
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="'statusType' === column.key"> <template v-if="'img' === column.dataIndex">
<!--状态--> <!-- <a-image :width="60" :src="record.img || $imageErr.imgErr" />-->
<a-tag <a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
v-if="statusUserTypeEnum.is('activated', record.status)" </template>
color="processing"> <template v-if="column.dataIndex === 'name'">
{{ statusUserTypeEnum.getDesc(record.status) }} <a-tooltip :title="record.name">
</a-tag> <span>{{ record.name }}</span>
<!--状态--> </a-tooltip>
<a-tag </template>
v-if="statusUserTypeEnum.is('freezed', record.status)" <template v-if="column.dataIndex === 'link'">
color="processing"> <a-tooltip :title="record.link">
{{ statusUserTypeEnum.getDesc(record.status) }} <span>{{ record.link }}</span>
</a-tag> </a-tooltip>
</template> </template>
<template v-if="'createAt' === column.key"> <template v-if="'status' === column.dataIndex">
{{ formatUtcDateTime(record.created_at) }} <a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
</template> </template>
<template v-if="'action' === column.key"> <template v-if="'action' === column.key">
<x-action-button @click="$refs.editDialogRef.handleEdit(record)"> <x-action-button @click="$refs.editDialogRef.handleEdit(record)">
<a-tooltip> <a-tooltip>
<template #title> {{ $t('pages.system.user.edit') }}</template> <template #title> {{ $t('pages.system.user.edit') }}</template>
<edit-outlined /> </a-tooltip <edit-outlined /> </a-tooltip></x-action-button>
></x-action-button>
<x-action-button @click="handleDelete(record)"> <x-action-button @click="handleDelete(record)">
<a-tooltip> <a-tooltip>
<template #title>{{ $t('pages.system.delete') }}</template> <template #title>{{ $t('pages.system.delete') }}</template>
<delete-outlined style="color: #ff4d4f" /> </a-tooltip <delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
></x-action-button>
</template> </template>
</template> </template>
</a-table> </a-table>
@ -106,9 +80,7 @@
</a-col> </a-col>
</a-row> </a-row>
<edit-dialog <edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
ref="editDialogRef"
@ok="onOk"></edit-dialog>
</template> </template>
<script setup> <script setup>
@ -123,18 +95,18 @@ import { usePagination } from '@/hooks'
import EditDialog from './components/EditDialog.vue' import EditDialog from './components/EditDialog.vue'
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue' import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { delMenu, getDataList } from '@/apis/modules/imgmgt'
defineOptions({ defineOptions({
name: 'friendlyLinks', name: 'friendlyLinks',
}) })
const { t } = useI18n() // t const { t } = useI18n() // t
const columns = [ const columns = [
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 }, { title: '图片', dataIndex: 'img', width: 100, align: 'center' },
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 }, { title: '名称', dataIndex: 'name', key: 'name' },
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 }, { title: '链接', dataIndex: 'link', key: 'link' },
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 }, { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 }, { title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 }, { title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 },
] ]
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
@ -150,8 +122,8 @@ async function getPageList() {
try { try {
showLoading() showLoading()
const { pageSize, current } = paginationState const { pageSize, current } = paginationState
const { success, data, total } = await apis.users const { success, data, total } = await apis.imgmgt
.getUsersList({ .getDataList({
pageSize, pageSize,
page: current, page: current,
...searchFormData.value, ...searchFormData.value,
@ -161,7 +133,8 @@ async function getPageList() {
}) })
hideLoading() hideLoading()
if (config('http.code.success') === success) { if (config('http.code.success') === success) {
listData.value = data //type10friendlyLinks
listData.value = data.filter(item => item.type===10)
paginationState.total = total paginationState.total = total
} }
} catch (error) { } catch (error) {
@ -179,9 +152,9 @@ function handleDelete({ id }) {
okText: t('button.confirm'), okText: t('button.confirm'),
onOk: () => { onOk: () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
;(async () => { ; (async () => {
try { try {
const { success } = await apis.users.delUsers(id).catch(() => { const { success } = await apis.imgmgt.delMenu(id).catch(() => {
throw new Error() throw new Error()
}) })
if (config('http.code.success') === success) { if (config('http.code.success') === success) {