generated from Leo_Ding/web-template
公司动态增删改查
This commit is contained in:
parent
8c933ddbf3
commit
f77d1391fa
@ -3,7 +3,6 @@ const modules = import.meta.glob('./modules/*.js', { eager: true })
|
||||
const api = {}
|
||||
Object.keys(modules).forEach((key) => {
|
||||
const name = key.slice(key.lastIndexOf('/') + 1, key.lastIndexOf('.'))
|
||||
console.log(name)
|
||||
api[name] = { ...modules[key] }
|
||||
})
|
||||
export default api
|
||||
|
||||
@ -5,3 +5,10 @@ export const getRegion = (params) => request.basic.get('/region', params)
|
||||
|
||||
// 获取 验证码ID
|
||||
export const getCaptcha = (params) => request.basic.get('/api/v1/captcha/id', params)
|
||||
|
||||
//上传图片
|
||||
export const uploadFile=(params)=>request.basic.post('/api/v1/upload',params,{
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
})
|
||||
|
||||
14
src/apis/modules/dynamic.js
Normal file
14
src/apis/modules/dynamic.js
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 海邻动态接口
|
||||
*/
|
||||
import request from '@/utils/request'
|
||||
// 获取公司动态列表
|
||||
export const getDataList = (params) => request.basic.get('/api/v1/articles', params)
|
||||
// 获取单条数据
|
||||
export const getItem = (id) => request.basic.get(`/api/v1/articles/${id}`)
|
||||
// 添加动态
|
||||
export const createDynamic = (params) => request.basic.post('/api/v1/articles', params)
|
||||
// 更新动态
|
||||
export const updateItem = (id, params) => request.basic.put(`/api/v1/articles/${id}`, params)
|
||||
// 删除动态
|
||||
export const delItem = (id) => request.basic.delete(`/api/v1/articles/${id}`)
|
||||
@ -1,26 +1,14 @@
|
||||
<template>
|
||||
<div
|
||||
ref="uploadImageRef"
|
||||
class="x-upload x-upload-image"
|
||||
:class="{
|
||||
<div ref="uploadImageRef" class="x-upload x-upload-image" :class="{
|
||||
'x-upload--round': round,
|
||||
'x-upload--disabled': disabled,
|
||||
}">
|
||||
<a-upload
|
||||
v-if="showUploadBtn"
|
||||
:show-upload-list="false"
|
||||
:multiple="multiple"
|
||||
:before-upload="onBeforeUpload"
|
||||
:custom-request="({ file }) => customRequest(file)"
|
||||
:accept="accept"
|
||||
:disabled="disabled">
|
||||
<a-upload v-if="showUploadBtn" :show-upload-list="false" :multiple="multiple" :before-upload="onBeforeUpload"
|
||||
:custom-request="({ file }) => customRequest(file)" :accept="accept" :disabled="disabled">
|
||||
<slot>
|
||||
<div
|
||||
class="x-upload-btn"
|
||||
:class="{
|
||||
<div class="x-upload-btn" :class="{
|
||||
'x-upload-btn--hover': !disabled,
|
||||
}"
|
||||
:style="{
|
||||
}" :style="{
|
||||
width: `${width}px`,
|
||||
height: `${height}px`,
|
||||
}">
|
||||
@ -29,9 +17,7 @@
|
||||
<plus-outlined></plus-outlined>
|
||||
</slot>
|
||||
</div>
|
||||
<div
|
||||
v-if="text"
|
||||
class="x-upload-btn__txt">
|
||||
<div v-if="text" class="x-upload-btn__txt">
|
||||
<slot name="text">
|
||||
{{ text }}
|
||||
</slot>
|
||||
@ -39,32 +25,20 @@
|
||||
</div>
|
||||
</slot>
|
||||
</a-upload>
|
||||
<div
|
||||
v-for="(item, index) in fileList"
|
||||
class="x-upload-item j-upload-item"
|
||||
:key="item.key"
|
||||
:class="{
|
||||
<div v-for="(item, index) in fileList" class="x-upload-item j-upload-item" :key="item.key" :class="{
|
||||
'x-upload-item--error': STATUS_ENUM.is('error', item.status),
|
||||
}"
|
||||
:style="{
|
||||
}" :style="{
|
||||
width: `${width}px`,
|
||||
height: `${height}px`,
|
||||
}">
|
||||
<img
|
||||
:src="item.src"
|
||||
alt="" />
|
||||
<img :src="item.src" alt="" />
|
||||
<template v-if="['error', 'done'].includes(STATUS_ENUM.getKey(item.status))">
|
||||
<div class="x-upload-actions">
|
||||
<div
|
||||
v-if="STATUS_ENUM.is('done', item.status)"
|
||||
class="x-upload-action"
|
||||
<div v-if="STATUS_ENUM.is('done', item.status)" class="x-upload-action"
|
||||
@click="handlePreview(item, index)">
|
||||
<eye-outlined />
|
||||
</div>
|
||||
<div
|
||||
v-if="!disabled"
|
||||
class="x-upload-action"
|
||||
@click="handleRemove(index)">
|
||||
<div v-if="!disabled" class="x-upload-action" @click="handleRemove(index)">
|
||||
<delete-outlined />
|
||||
</div>
|
||||
</div>
|
||||
@ -73,16 +47,11 @@
|
||||
<div class="x-upload-status">
|
||||
<template v-if="STATUS_ENUM.is('uploading', item.status)">
|
||||
<div>{{ item.percent }}%</div>
|
||||
<a-progress
|
||||
:show-info="false"
|
||||
:stroke-width="4"
|
||||
:percent="item.percent" />
|
||||
<a-progress :show-info="false" :stroke-width="4" :percent="item.percent" />
|
||||
</template>
|
||||
<template v-if="STATUS_ENUM.is('wait', item.status)">
|
||||
<div>{{ STATUS_ENUM.getDesc(item.status) }}</div>
|
||||
<span
|
||||
class="x-upload-action"
|
||||
@click="handleCancel(item)">
|
||||
<span class="x-upload-action" @click="handleCancel(item)">
|
||||
取消上传
|
||||
</span>
|
||||
</template>
|
||||
@ -92,11 +61,7 @@
|
||||
</div>
|
||||
|
||||
<!--裁剪-->
|
||||
<cropper-dialog
|
||||
v-if="cropper && !multiple"
|
||||
ref="cropperDialogRef"
|
||||
:aspect-ratio="aspectRatio"
|
||||
:quality="quality"
|
||||
<cropper-dialog v-if="cropper && !multiple" ref="cropperDialogRef" :aspect-ratio="aspectRatio" :quality="quality"
|
||||
@ok="(file) => customRequest(file)" />
|
||||
</template>
|
||||
|
||||
@ -113,7 +78,9 @@ import { deepMerge } from '@/utils/util'
|
||||
import CropperDialog from '../Cropper/CropperDialog.vue'
|
||||
import Preview from '../Preview'
|
||||
import { STATUS_ENUM } from './config'
|
||||
|
||||
import apis from '@/apis'
|
||||
import axios from 'axios'
|
||||
import { config } from '@/config'
|
||||
defineOptions({
|
||||
name: 'XUploadImage',
|
||||
})
|
||||
@ -188,7 +155,7 @@ const props = defineProps({
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
const emit = defineEmits(['update:modelValue','imgChange'])
|
||||
|
||||
useSlots(['icon', 'text'])
|
||||
|
||||
@ -369,27 +336,30 @@ async function doUpload() {
|
||||
record.status = STATUS_ENUM.getValue('uploading')
|
||||
|
||||
// 模拟示例
|
||||
record.percent = 100
|
||||
record.status = STATUS_ENUM.getValue('done')
|
||||
trigger()
|
||||
await doUpload()
|
||||
// record.percent = 100
|
||||
// record.status = STATUS_ENUM.getValue('done')
|
||||
// trigger()
|
||||
// await doUpload()
|
||||
|
||||
// 接口示例
|
||||
// const { code } = await apis.common.upload({
|
||||
// file: record?.file,
|
||||
// })
|
||||
// if (config('http.code.success') === code) {
|
||||
// // 上传进度
|
||||
// record.percent = 100
|
||||
// // 上传状态,根据实际情况更新
|
||||
// record.status = STATUS_ENUM.getValue('done')
|
||||
// // 更新文件 url
|
||||
// record.src = data?.src
|
||||
// // 触发事件
|
||||
// trigger()
|
||||
// // 递归上传,检查是否还有未上传的文件
|
||||
// await doUpload()
|
||||
// }
|
||||
const formData = new FormData();
|
||||
// 添加文件
|
||||
formData.append('file', record.file);
|
||||
const { success,data } = await apis.common.uploadFile(formData)
|
||||
if (config('http.code.success') === success) {
|
||||
// 上传进度
|
||||
record.percent = 100
|
||||
// 上传状态,根据实际情况更新
|
||||
record.status = STATUS_ENUM.getValue('done')
|
||||
// 更新文件 url
|
||||
// record.src = success?.data
|
||||
// 触发事件
|
||||
emit('imgChange', data)
|
||||
// 递归上传,检查是否还有未上传的文件
|
||||
await doUpload()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -421,6 +391,7 @@ function trigger() {
|
||||
// 单选
|
||||
value = (fileList.value.length ? fileList.value[0]?.src : fileList.value[0]) ?? ''
|
||||
}
|
||||
console.log(value)
|
||||
emit('update:modelValue', value)
|
||||
onFieldChange()
|
||||
}
|
||||
@ -434,6 +405,7 @@ function trigger() {
|
||||
|
||||
// 圆角
|
||||
&--round {
|
||||
|
||||
.x-upload-btn,
|
||||
.x-upload-item {
|
||||
border-radius: 10em;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { active } from "sortablejs";
|
||||
|
||||
|
||||
export default [
|
||||
{
|
||||
|
||||
@ -4,7 +4,7 @@ import list from './list'
|
||||
import profile from './profile'
|
||||
import result from './result'
|
||||
import exception from './exception'
|
||||
// import admin from './admin'
|
||||
import admin from './admin'
|
||||
import system from './system'
|
||||
import link from './link'
|
||||
import iframe from './iframe'
|
||||
@ -19,7 +19,7 @@ export default [
|
||||
...profile,
|
||||
...result,
|
||||
...exception,
|
||||
// ...admin,
|
||||
...admin,
|
||||
...system,
|
||||
...link,
|
||||
...iframe,
|
||||
|
||||
@ -87,7 +87,6 @@ const basic = new XYHttp({
|
||||
...options,
|
||||
baseURL: config('http.apiBasic'),
|
||||
})
|
||||
console.log(basic)
|
||||
const readFile = new ReadFile()
|
||||
export default {
|
||||
basic,
|
||||
|
||||
@ -1,114 +1,37 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:open="modal.open"
|
||||
:title="modal.title"
|
||||
: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-modal :open="modal.open" :title="modal.title" :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">
|
||||
<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-col :span="24">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.remark')"
|
||||
name="remark">
|
||||
<a-textarea
|
||||
:placeholder="$t('pages.system.user.form.remark.placeholder')"
|
||||
v-model:value="formData.remark"></a-textarea>
|
||||
<a-form-item :label="'标题'" name="title">
|
||||
<a-input :placeholder="'请输入标题'" v-model:value="formData.title"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="24">
|
||||
<a-form-item
|
||||
:label="$t('pages.system.user.form.status')"
|
||||
name="status">
|
||||
<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-form-item :label="'内容'" name="content">
|
||||
<a-textarea :placeholder="'内容'" v-model:value="formData.content"></a-textarea>
|
||||
</a-form-item>
|
||||
</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="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-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
@ -123,6 +46,7 @@ import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import dayjs from 'dayjs'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
@ -131,18 +55,16 @@ const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
const rolesValue = ref([])
|
||||
const roles = ref([])
|
||||
|
||||
const imgUrl=ref('')
|
||||
formRules.value = {
|
||||
name: { required: true, message: t('pages.system.user.form.username.placeholder') },
|
||||
username: { required: true, message: t('pages.system.user.form.code.placeholder') },
|
||||
status: { required: true, message: t('pages.system.user.form.status') },
|
||||
roles: [{ required: true, message: t('pages.system.user.form.roles.placeholder'), trigger: 'change' }],
|
||||
title: { required: true, message: '请输入标题' },
|
||||
content: { required: true, message: '请输入内容' },
|
||||
link: { required: true, message: '请输入链接' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
// imgUrl: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求角色
|
||||
*/
|
||||
getRole()
|
||||
|
||||
|
||||
/**
|
||||
* select 选择框
|
||||
@ -150,34 +72,21 @@ getRole()
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
|
||||
const imgChange=(value)=>{
|
||||
formData.value.img=value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
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,44 +95,40 @@ async function handleEdit(record = {}) {
|
||||
type: '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) {
|
||||
hideModal()
|
||||
return
|
||||
}
|
||||
let roles = []
|
||||
if (data.roles) {
|
||||
roles = formatArr(data.roles, 'edit')
|
||||
}
|
||||
|
||||
data.roles = roles
|
||||
formRecord.value = data
|
||||
formData.value = cloneDeep(data)
|
||||
formData.value = {...data}
|
||||
imgUrl.value=config('http.apiBasic')+data.img
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
if(!formData.value.img) return message.error('请上传图片');
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
console.log(values)
|
||||
try {
|
||||
showLoading()
|
||||
|
||||
const params = {
|
||||
...values,
|
||||
roles: formatArr(rolesValue.value),
|
||||
img:formData.value.img,
|
||||
pushAt:dayjs().format('YYYY-MM-DD'),
|
||||
type:'news'
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.users.createUsers(params).catch(() => {
|
||||
result = await apis.dynamic.createDynamic(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
|
||||
result = await apis.dynamic.updateItem(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
@ -234,10 +139,12 @@ function handleOk() {
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
@ -273,6 +180,7 @@ function formatArr(data, type = '') {
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
imgUrl.value=''
|
||||
hideModal()
|
||||
}
|
||||
|
||||
|
||||
@ -1,44 +1,28 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form
|
||||
:label-col="{ style: { width: '100px' } }"
|
||||
:model="searchFormData"
|
||||
layout="inline">
|
||||
<a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<a-col v-bind="colSpan">
|
||||
<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="searchFormData.username"></a-input>
|
||||
<a-form-item label="标题" name="title">
|
||||
<a-input placeholder="请输入公司动态标题" v-model:value="searchFormData.title"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col v-bind="colSpan">
|
||||
<a-form-item name="name">
|
||||
<template #label>
|
||||
{{ $t('pages.system.user.form.name') }}
|
||||
<a-tooltip :title="$t('pages.system.user.form.name')">
|
||||
<question-circle-outlined class="ml-4-1 color-placeholder" />
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<a-input
|
||||
:placeholder="$t('pages.system.user.form.name.placeholder')"
|
||||
v-model:value="searchFormData.name"></a-input>
|
||||
<a-form-item label="状态" name="status">
|
||||
<a-select v-model:value="searchFormData.status" allowClear>
|
||||
<a-select-option value="">全部</a-select-option>
|
||||
<a-select-option value="enabled">启用</a-select-option>
|
||||
<a-select-option value="disabled">停用</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col
|
||||
class="align-right"
|
||||
v-bind="colSpan">
|
||||
<a-col class="align-right" v-bind="colSpan">
|
||||
<a-space>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button
|
||||
ghost
|
||||
type="primary"
|
||||
@click="handleSearch">
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
@ -47,58 +31,52 @@
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
<a-row
|
||||
:gutter="8"
|
||||
:wrap="false">
|
||||
<a-row :gutter="8" :wrap="false">
|
||||
<a-col flex="auto">
|
||||
<a-card type="flex">
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button
|
||||
type="primary"
|
||||
@click="$refs.editDialogRef.handleCreate()">
|
||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
{{ $t('pages.system.user.add') }}
|
||||
添加动态
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table
|
||||
:columns="columns"
|
||||
:data-source="listData"
|
||||
:loading="loading"
|
||||
:pagination="paginationState"
|
||||
:scroll="{ x: 1000 }"
|
||||
@change="onTableChange">
|
||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'statusType' === column.key">
|
||||
<!--状态-->
|
||||
<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 v-if="'img' === column.dataIndex">
|
||||
<a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
<template v-if="column.dataIndex === 'title'">
|
||||
<a-tooltip :title="record.title">
|
||||
<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 v-if="'action' === column.key">
|
||||
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||
<a-tooltip>
|
||||
<template #title> {{ $t('pages.system.user.edit') }}</template>
|
||||
<edit-outlined /> </a-tooltip
|
||||
></x-action-button>
|
||||
<edit-outlined /> </a-tooltip></x-action-button>
|
||||
<x-action-button @click="handleDelete(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip
|
||||
></x-action-button>
|
||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
@ -106,9 +84,7 @@
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog
|
||||
ref="editDialogRef"
|
||||
@ok="onOk"></edit-dialog>
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -124,17 +100,17 @@ import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
defineOptions({
|
||||
name: 'companyNews',
|
||||
name: 'homeBanner',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
{ title: t('pages.system.user.form.username'), dataIndex: 'username', width: 120 },
|
||||
{ title: t('pages.system.user.form.name'), dataIndex: 'name', key: 'name', width: 100 },
|
||||
{ title: t('pages.system.user.form.phone'), dataIndex: 'phone', width: 120 },
|
||||
{ title: t('pages.system.user.form.email'), dataIndex: 'email', width: 100 },
|
||||
{ title: t('pages.system.user.form.status'), dataIndex: 'status', key: 'statusType', width: 60 },
|
||||
{ title: t('pages.system.user.form.created_at'), key: 'createAt', fixed: 'right', width: 120 },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100 },
|
||||
{ title: '图片', dataIndex: 'img', width: 100, align: 'center' },
|
||||
{ title: '标题', dataIndex: 'title', key: 'title' },
|
||||
{ title: '内容', dataIndex: 'content', key: 'content' },
|
||||
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||
{ 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 } =
|
||||
@ -150,8 +126,8 @@ async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.users
|
||||
.getUsersList({
|
||||
const { success, data, total } = await apis.dynamic
|
||||
.getDataList({
|
||||
pageSize,
|
||||
page: current,
|
||||
...searchFormData.value,
|
||||
@ -181,7 +157,7 @@ function handleDelete({ id }) {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.users.delUsers(id).catch(() => {
|
||||
const { success } = await apis.dynamic.delItem(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user