generated from Leo_Ding/web-template
photo all
This commit is contained in:
parent
a1b602c18a
commit
cd01496a5c
@ -1,114 +1,32 @@
|
||||
<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="name">
|
||||
<a-input :placeholder="'请输入名称'" v-model:value="formData.name"></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="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-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
@ -123,6 +41,8 @@ import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import dayjs from 'dayjs'
|
||||
import { createMenu, getMenu, updateMenu } from '@/apis/modules/imgmgt'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
@ -131,53 +51,34 @@ const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
const rolesValue = ref([])
|
||||
const roles = ref([])
|
||||
|
||||
const img = 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' }],
|
||||
name: { required: true, message: '请输入名称' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求角色
|
||||
*/
|
||||
getRole()
|
||||
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
|
||||
const imgChange = (value) => {
|
||||
formData.value.img = value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: t('pages.system.user.add'),
|
||||
// 80对应about
|
||||
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 +87,44 @@ 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.imgmgt.getMenu(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 }
|
||||
formData.value.pushAt=dayjs(data.pushAt)
|
||||
console.log(formData.value)
|
||||
img.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(formData.value.pushAt).format("YYYY-MM-DD"),
|
||||
type: 100 ,
|
||||
// 100对应corporateHonor
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.users.createUsers(params).catch(() => {
|
||||
result = await apis.imgmgt.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
|
||||
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
@ -234,10 +135,12 @@ function handleOk() {
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
@ -273,6 +176,7 @@ function formatArr(data, type = '') {
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
img.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="name">
|
||||
<a-input placeholder="请输入图片名称" v-model:value="searchFormData.name"></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,43 @@
|
||||
</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="record.img || $imageErr.imgErr" />-->
|
||||
<a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'name'">
|
||||
<a-tooltip :title="record.name">
|
||||
<span>{{ record.name }}</span>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
<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 +75,7 @@
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog
|
||||
ref="editDialogRef"
|
||||
@ok="onOk"></edit-dialog>
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -123,18 +90,17 @@ import { usePagination } from '@/hooks'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { delMenu, getDataList } from '@/apis/modules/imgmgt'
|
||||
defineOptions({
|
||||
name: 'corporateHonor',
|
||||
})
|
||||
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: 'name', key: 'name' },
|
||||
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||
{ title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||
]
|
||||
|
||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||
@ -150,8 +116,8 @@ async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.users
|
||||
.getUsersList({
|
||||
const { success, data, total } = await apis.imgmgt
|
||||
.getDataList({
|
||||
pageSize,
|
||||
page: current,
|
||||
...searchFormData.value,
|
||||
@ -161,7 +127,8 @@ async function getPageList() {
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data
|
||||
//筛选type的值100对应corporateHonor
|
||||
listData.value = data.filter( item => item.type===100)
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
@ -179,9 +146,9 @@ function handleDelete({ id }) {
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.users.delUsers(id).catch(() => {
|
||||
const { success } = await apis.imgmgt.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
|
||||
@ -1,114 +1,32 @@
|
||||
<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="name">
|
||||
<a-input :placeholder="'请输入名称'" v-model:value="formData.name"></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="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-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
@ -123,6 +41,8 @@ import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import dayjs from 'dayjs'
|
||||
import { createMenu, getMenu, updateMenu } from '@/apis/modules/imgmgt'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
@ -131,53 +51,34 @@ const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
const rolesValue = ref([])
|
||||
const roles = ref([])
|
||||
|
||||
const img = 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' }],
|
||||
name: { required: true, message: '请输入名称' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求角色
|
||||
*/
|
||||
getRole()
|
||||
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
|
||||
const imgChange = (value) => {
|
||||
formData.value.img = value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: t('pages.system.user.add'),
|
||||
// 80对应about
|
||||
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 +87,44 @@ 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.imgmgt.getMenu(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 }
|
||||
formData.value.pushAt=dayjs(data.pushAt)
|
||||
console.log(formData.value)
|
||||
img.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(formData.value.pushAt).format("YYYY-MM-DD"),
|
||||
type: 110 ,
|
||||
// 110对应researchHonor
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.users.createUsers(params).catch(() => {
|
||||
result = await apis.imgmgt.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
|
||||
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
@ -234,10 +135,12 @@ function handleOk() {
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
@ -273,6 +176,7 @@ function formatArr(data, type = '') {
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
img.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="name">
|
||||
<a-input placeholder="请输入图片名称" v-model:value="searchFormData.name"></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,43 @@
|
||||
</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="record.img || $imageErr.imgErr" />-->
|
||||
<a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'name'">
|
||||
<a-tooltip :title="record.name">
|
||||
<span>{{ record.name }}</span>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
<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 +75,7 @@
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog
|
||||
ref="editDialogRef"
|
||||
@ok="onOk"></edit-dialog>
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -123,18 +90,17 @@ import { usePagination } from '@/hooks'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { delMenu, getDataList } from '@/apis/modules/imgmgt'
|
||||
defineOptions({
|
||||
name: 'researchHonor',
|
||||
})
|
||||
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: 'name', key: 'name' },
|
||||
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||
{ title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||
]
|
||||
|
||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||
@ -150,8 +116,8 @@ async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.users
|
||||
.getUsersList({
|
||||
const { success, data, total } = await apis.imgmgt
|
||||
.getDataList({
|
||||
pageSize,
|
||||
page: current,
|
||||
...searchFormData.value,
|
||||
@ -161,7 +127,8 @@ async function getPageList() {
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data
|
||||
//筛选type的值110对应researchHonor
|
||||
listData.value = data.filter(item => item.type===110)
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
@ -179,9 +146,9 @@ function handleDelete({ id }) {
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.users.delUsers(id).catch(() => {
|
||||
const { success } = await apis.imgmgt.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
|
||||
@ -1,114 +1,32 @@
|
||||
<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="name">
|
||||
<a-input :placeholder="'请输入名称'" v-model:value="formData.name"></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="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-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
@ -123,6 +41,8 @@ import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import dayjs from 'dayjs'
|
||||
import { createMenu, getMenu, updateMenu } from '@/apis/modules/imgmgt'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
@ -131,53 +51,34 @@ const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
const rolesValue = ref([])
|
||||
const roles = ref([])
|
||||
|
||||
const img = 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' }],
|
||||
name: { required: true, message: '请输入名称' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求角色
|
||||
*/
|
||||
getRole()
|
||||
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
|
||||
const imgChange = (value) => {
|
||||
formData.value.img = value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: t('pages.system.user.add'),
|
||||
// 80对应about
|
||||
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 +87,44 @@ 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.imgmgt.getMenu(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 }
|
||||
formData.value.pushAt=dayjs(data.pushAt)
|
||||
console.log(formData.value)
|
||||
img.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(formData.value.pushAt).format("YYYY-MM-DD"),
|
||||
type: 90 ,
|
||||
// 90对应talentCenter
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.users.createUsers(params).catch(() => {
|
||||
result = await apis.imgmgt.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
|
||||
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
@ -234,10 +135,12 @@ function handleOk() {
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
@ -273,6 +176,7 @@ function formatArr(data, type = '') {
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
img.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="name">
|
||||
<a-input placeholder="请输入图片名称" v-model:value="searchFormData.name"></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,43 @@
|
||||
</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="record.img || $imageErr.imgErr" />-->
|
||||
<a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'name'">
|
||||
<a-tooltip :title="record.name">
|
||||
<span>{{ record.name }}</span>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
<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 +75,7 @@
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog
|
||||
ref="editDialogRef"
|
||||
@ok="onOk"></edit-dialog>
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -123,18 +90,17 @@ import { usePagination } from '@/hooks'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { delMenu, getDataList } from '@/apis/modules/imgmgt'
|
||||
defineOptions({
|
||||
name: 'talentCenter',
|
||||
})
|
||||
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: 'name', key: 'name' },
|
||||
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||
{ title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||
]
|
||||
|
||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||
@ -150,8 +116,8 @@ async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.users
|
||||
.getUsersList({
|
||||
const { success, data, total } = await apis.imgmgt
|
||||
.getDataList({
|
||||
pageSize,
|
||||
page: current,
|
||||
...searchFormData.value,
|
||||
@ -161,7 +127,8 @@ async function getPageList() {
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data
|
||||
//筛选type的值90对应talentCenter
|
||||
listData.value = data.filter(item => item.type===90)
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
@ -179,9 +146,9 @@ function handleDelete({ id }) {
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.users.delUsers(id).catch(() => {
|
||||
const { success } = await apis.imgmgt.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
|
||||
@ -1,114 +1,32 @@
|
||||
<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="name">
|
||||
<a-input :placeholder="'请输入名称'" v-model:value="formData.name"></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="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-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
@ -123,6 +41,8 @@ import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import dayjs from 'dayjs'
|
||||
import { createMenu, getMenu, updateMenu } from '@/apis/modules/imgmgt'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
@ -131,53 +51,34 @@ const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
const rolesValue = ref([])
|
||||
const roles = ref([])
|
||||
|
||||
const img = 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' }],
|
||||
name: { required: true, message: '请输入名称' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求角色
|
||||
*/
|
||||
getRole()
|
||||
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
|
||||
const imgChange = (value) => {
|
||||
formData.value.img = value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: t('pages.system.user.add'),
|
||||
// 80对应about
|
||||
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 +87,44 @@ 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.imgmgt.getMenu(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 }
|
||||
formData.value.pushAt=dayjs(data.pushAt)
|
||||
console.log(formData.value)
|
||||
img.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(formData.value.pushAt).format("YYYY-MM-DD"),
|
||||
type: 70 ,
|
||||
// 70对应teamStyle
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.users.createUsers(params).catch(() => {
|
||||
result = await apis.imgmgt.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.users.updateUsers(formData.value.id, params).catch(() => {
|
||||
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
@ -234,10 +135,12 @@ function handleOk() {
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
@ -273,6 +176,7 @@ function formatArr(data, type = '') {
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
img.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="name">
|
||||
<a-input placeholder="请输入图片名称" v-model:value="searchFormData.name"></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,43 @@
|
||||
</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="record.img || $imageErr.imgErr" />-->
|
||||
<a-image :width="60" :src="config('http.apiBasic') + record.img || $imageErr.imgErr" />
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'name'">
|
||||
<a-tooltip :title="record.name">
|
||||
<span>{{ record.name }}</span>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
||||
<template v-if="'createAt' === column.key">
|
||||
{{ formatUtcDateTime(record.created_at) }}
|
||||
<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 +75,7 @@
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog
|
||||
ref="editDialogRef"
|
||||
@ok="onOk"></edit-dialog>
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -123,18 +90,17 @@ import { usePagination } from '@/hooks'
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { delMenu, getDataList } from '@/apis/modules/imgmgt'
|
||||
defineOptions({
|
||||
name: 'teamStyle',
|
||||
})
|
||||
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: 'name', key: 'name' },
|
||||
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||
{ title: '顺序', dataIndex: 'sequence', width: 100, align: 'center' },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||
]
|
||||
|
||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||
@ -150,8 +116,8 @@ async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.users
|
||||
.getUsersList({
|
||||
const { success, data, total } = await apis.imgmgt
|
||||
.getDataList({
|
||||
pageSize,
|
||||
page: current,
|
||||
...searchFormData.value,
|
||||
@ -161,7 +127,8 @@ async function getPageList() {
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data
|
||||
//筛选type的值90对应talentCenter
|
||||
listData.value = data.filter(item => item.type===70)
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
@ -179,9 +146,9 @@ function handleDelete({ id }) {
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.users.delUsers(id).catch(() => {
|
||||
const { success } = await apis.imgmgt.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user