generated from Leo_Ding/web-template
菜单-联系我们未改
This commit is contained in:
parent
f4c72e7859
commit
2375cddadb
4
.env.dev
4
.env.dev
@ -12,8 +12,8 @@ VITE_ROUTER_BASE=/
|
||||
VITE_ROUTER_HISTORY=hash
|
||||
|
||||
# api
|
||||
#VITE_API_BASIC=https://api.hailin-keji.com
|
||||
VITE_API_BASIC=http://10.10.1.6:8060
|
||||
VITE_API_BASIC=https://api.hailin-keji.com
|
||||
#VITE_API_BASIC=http://10.10.1.6:8060
|
||||
VITE_API_HTTP=/api/v1/
|
||||
# storage
|
||||
VITE_STORAGE_NAMESPACE = gin-admin_local_
|
||||
|
||||
@ -32,12 +32,13 @@ export default {
|
||||
account: '个人页',
|
||||
'account.trigger': '触发报错',
|
||||
'account.logout': '退出登录',
|
||||
imgMgt:'图片管理',
|
||||
imgMgt:'首页',
|
||||
homeBanner:'首页轮播图',
|
||||
about:'关于海邻',
|
||||
about:'关于海邻左侧背景图',
|
||||
researchHonor:'科研成果',
|
||||
AboutY:'关于海邻',
|
||||
corporateHonor:'企业荣誉',
|
||||
talentCenter:'办公环境',
|
||||
talentCenter:'人才中心',
|
||||
teamStyle:'团队风采',
|
||||
Dynamic:'海邻动态',
|
||||
companyNews:'公司动态',
|
||||
@ -46,10 +47,16 @@ export default {
|
||||
recruitment:'招聘岗位',
|
||||
product:'产品中心',
|
||||
team:'技术团队',
|
||||
importantEvents:'海邻大事记',
|
||||
importantEvents:'发展历程',
|
||||
websiteRelated:'网站相关',
|
||||
friendlyLinks:'友情链接',
|
||||
websiteStatement:'网站声明',
|
||||
contactUs:'联系我们',
|
||||
productType:'产品分类'
|
||||
productType:'产品分类',
|
||||
productY:'产品中心',
|
||||
productCentre:'产品中心',
|
||||
productClassify:'产品分类',
|
||||
technologyCenter:'技术中心',
|
||||
environment:'办公环境',
|
||||
|
||||
}
|
||||
|
||||
51
src/router/routes/AboutY.js
Normal file
51
src/router/routes/AboutY.js
Normal file
@ -0,0 +1,51 @@
|
||||
import { PictureOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
export default [
|
||||
{
|
||||
path: 'AboutY',
|
||||
name: 'AboutY',
|
||||
component: 'RouteViewLayout',
|
||||
meta: {
|
||||
icon: PictureOutlined,
|
||||
title: '关于海邻',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
children: [
|
||||
// {
|
||||
// path: 'Profile',
|
||||
// name: 'Profile',
|
||||
// component: 'AboutY/Profile/index.vue',
|
||||
// meta: {
|
||||
// title: '企业简介',
|
||||
// isMenu: true,
|
||||
// keepAlive: true,
|
||||
// permission: '*',
|
||||
// },
|
||||
// },
|
||||
{
|
||||
path: 'importantEvents',
|
||||
name: 'importantEvents',
|
||||
component: 'AboutY/importantEvents/index.vue',
|
||||
meta: {
|
||||
title: '发展历程',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'researchHonor',
|
||||
name: 'researchHonor',
|
||||
component: 'AboutY/researchHonor/index.vue',
|
||||
meta: {
|
||||
title: '企业荣誉',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
@ -46,39 +46,39 @@ export default [
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'corporateHonor',
|
||||
name: 'corporateHonor',
|
||||
component: 'imgMgt/corporateHonor/index.vue',
|
||||
meta: {
|
||||
title: '企业荣誉',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'talentCenter',
|
||||
name: 'talentCenter',
|
||||
component: 'imgMgt/talentCenter/index.vue',
|
||||
meta: {
|
||||
title: '人才中心',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'teamStyle',
|
||||
name: 'teamStyle',
|
||||
component: 'imgMgt/teamStyle/index.vue',
|
||||
meta: {
|
||||
title: '团队风采',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
// {
|
||||
// path: 'corporateHonor',
|
||||
// name: 'corporateHonor',
|
||||
// component: 'imgMgt/corporateHonor/index.vue',
|
||||
// meta: {
|
||||
// title: '企业荣誉',
|
||||
// isMenu: true,
|
||||
// keepAlive: true,
|
||||
// permission: '*',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// path: 'talentCenter',
|
||||
// name: 'talentCenter',
|
||||
// component: 'imgMgt/talentCenter/index.vue',
|
||||
// meta: {
|
||||
// title: '人才中心',
|
||||
// isMenu: true,
|
||||
// keepAlive: true,
|
||||
// permission: '*',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// path: 'teamStyle',
|
||||
// name: 'teamStyle',
|
||||
// component: 'imgMgt/teamStyle/index.vue',
|
||||
// meta: {
|
||||
// title: '团队风采',
|
||||
// isMenu: true,
|
||||
// keepAlive: true,
|
||||
// permission: '*',
|
||||
// },
|
||||
// },
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
import { ScheduleOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
export default [
|
||||
{
|
||||
path: 'importantEvents',
|
||||
name: 'importantEvents',
|
||||
component: 'importantEvents/index.vue',
|
||||
meta: {
|
||||
icon: ScheduleOutlined,
|
||||
title: '海邻大事记',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
]
|
||||
@ -11,12 +11,12 @@ import iframe from './iframe'
|
||||
import other from './other'
|
||||
import imgMgt from './imgMgt'
|
||||
import dynamic from './dynamic'
|
||||
import recruitment from './recruitment'
|
||||
// import recruitment from './recruitment'
|
||||
import product from './product'
|
||||
import team from './team'
|
||||
import importantEvents from './importantEvents'
|
||||
import technologyCenter from './technologyCenter'
|
||||
import website from './websiteRelated'
|
||||
|
||||
import AboutY from './AboutY'
|
||||
import talentCenter from './talentCenter'
|
||||
export default [
|
||||
...home,
|
||||
...form,
|
||||
@ -31,9 +31,10 @@ export default [
|
||||
...other,
|
||||
...imgMgt,
|
||||
...dynamic,
|
||||
...recruitment,
|
||||
//...recruitment,
|
||||
...product,
|
||||
...team,
|
||||
...importantEvents,
|
||||
...technologyCenter,
|
||||
...website,
|
||||
...AboutY,
|
||||
...talentCenter,
|
||||
]
|
||||
|
||||
@ -1,28 +1,68 @@
|
||||
import { ShoppingOutlined } from '@ant-design/icons-vue'
|
||||
// import { ShoppingOutlined } from '@ant-design/icons-vue'
|
||||
//
|
||||
// export default [
|
||||
// {
|
||||
// path: 'product',
|
||||
// name: 'product',
|
||||
// component: 'product/index.vue',
|
||||
// meta: {
|
||||
// icon: ShoppingOutlined,
|
||||
// title: '产品中心',
|
||||
// isMenu: true,
|
||||
// keepAlive: true,
|
||||
// permission: '*',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// path: 'productType',
|
||||
// name: 'productType',
|
||||
// component: 'productType/index.vue',
|
||||
// meta: {
|
||||
// icon: ShoppingOutlined,
|
||||
// title: '产品分类',
|
||||
// isMenu: true,
|
||||
// keepAlive: true,
|
||||
// permission: '*',
|
||||
// },
|
||||
// },
|
||||
// ]
|
||||
import { PictureOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
export default [
|
||||
{
|
||||
path: 'product',
|
||||
name: 'product',
|
||||
component: 'product/index.vue',
|
||||
path: 'productY',
|
||||
name: 'productY',
|
||||
component: 'RouteViewLayout',
|
||||
meta: {
|
||||
icon: ShoppingOutlined,
|
||||
icon: PictureOutlined,
|
||||
title: '产品中心',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'productType',
|
||||
name: 'productType',
|
||||
component: 'productType/index.vue',
|
||||
meta: {
|
||||
icon: ShoppingOutlined,
|
||||
title: '产品分类',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'productClassify',
|
||||
name: 'productClassify',
|
||||
component: 'productY/productClassify/index.vue',
|
||||
meta: {
|
||||
title: '产品分类',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'productCentre',
|
||||
name: 'productCentre',
|
||||
component: 'productY/productCentre/index.vue',
|
||||
meta: {
|
||||
title: '产品中心',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
50
src/router/routes/talentCenter.js
Normal file
50
src/router/routes/talentCenter.js
Normal file
@ -0,0 +1,50 @@
|
||||
import { PictureOutlined } from '@ant-design/icons-vue'
|
||||
export default [
|
||||
{
|
||||
path: 'talentCenter',
|
||||
name: 'talentCenter',
|
||||
component: 'RouteViewLayout',
|
||||
meta: {
|
||||
icon: PictureOutlined,
|
||||
title: '图片管理',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'environment',
|
||||
name: 'environment',
|
||||
component: 'talentCenter/environment/index.vue',
|
||||
meta: {
|
||||
title: '办公环境',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'teamStyle',
|
||||
name: 'teamStyle',
|
||||
component: 'talentCenter/teamStyle/index.vue',
|
||||
meta: {
|
||||
title: '团队风采',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'recruitment',
|
||||
name: 'recruitment',
|
||||
component: 'talentCenter/recruitment/index.vue',
|
||||
meta: {
|
||||
title: '招聘岗位',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
29
src/router/routes/technologyCenter.js
Normal file
29
src/router/routes/technologyCenter.js
Normal file
@ -0,0 +1,29 @@
|
||||
import { PictureOutlined } from '@ant-design/icons-vue'
|
||||
|
||||
export default [
|
||||
{
|
||||
path: 'technologyCenter',
|
||||
name: 'technologyCenter',
|
||||
component: 'RouteViewLayout',
|
||||
meta: {
|
||||
icon: PictureOutlined,
|
||||
title: '技术中心',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'team',
|
||||
name: 'team',
|
||||
component: 'technologyCenter/team/index.vue',
|
||||
meta: {
|
||||
title: '技术团队',
|
||||
isMenu: true,
|
||||
keepAlive: true,
|
||||
permission: '*',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
197
src/views/AboutY/corporateHonor/components/EditDialog.vue
Normal file
197
src/views/AboutY/corporateHonor/components/EditDialog.vue
Normal file
@ -0,0 +1,197 @@
|
||||
<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">
|
||||
<a-card class="mb-8-2">
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'名称'" name="name">
|
||||
<a-input :placeholder="'请输入名称'" v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'顺序'" name="sequence">
|
||||
<a-input-number :placeholder="'请输入顺序'" v-model:value="formData.sequence"></a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'状态'" name="status">
|
||||
<a-radio-group v-model:value="formData.status" :options="[
|
||||
{ label: '启用', value: 'enabled' },
|
||||
{ label: '停用', value: 'disabled' },
|
||||
]"></a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'图片'" name="img">
|
||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
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()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
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: '请输入名称' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
const imgChange = (value) => {
|
||||
formData.value.img = value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
// 80对应about
|
||||
title: '添加',
|
||||
})
|
||||
formData.value.status = 'enabled'
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: t('pages.system.user.edit'),
|
||||
})
|
||||
const { data, success } = await apis.imgmgt.getMenu(record.id).catch()
|
||||
if (!success) {
|
||||
hideModal()
|
||||
return
|
||||
}
|
||||
formData.value = { ...data }
|
||||
formData.value.pushAt=dayjs(data.pushAt)
|
||||
console.log(formData.value)
|
||||
img.value = config('http.apiBasic') + data.img
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
if (!formData.value.img) return message.error('请上传图片');
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
console.log(values)
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
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.imgmgt.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 对权限组 过数据格式
|
||||
*/
|
||||
function formatArr(data, type = '') {
|
||||
const rolesArr = []
|
||||
data.forEach((item) => {
|
||||
roles.value.forEach((r) => {
|
||||
if (type === 'edit') {
|
||||
if (item.role_id === r.value) {
|
||||
rolesArr.push({
|
||||
value: item.role_id,
|
||||
label: r.label,
|
||||
})
|
||||
return
|
||||
}
|
||||
} else if (r.value === item) {
|
||||
rolesArr.push({
|
||||
role_id: item,
|
||||
role_name: r.label,
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
})
|
||||
return rolesArr
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
img.value = ''
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
202
src/views/AboutY/corporateHonor/index.vue
Normal file
202
src/views/AboutY/corporateHonor/index.vue
Normal file
@ -0,0 +1,202 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<a-col v-bind="colSpan">
|
||||
<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 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-space>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
<a-row :gutter="8" :wrap="false">
|
||||
<a-col flex="auto">
|
||||
<a-card type="flex">
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
新增
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'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="'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>
|
||||
<x-action-button @click="handleDelete(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ref } from 'vue'
|
||||
import apis from '@/apis'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import { config } from '@/config'
|
||||
import { statusUserTypeEnum } from '@/enums/system'
|
||||
import { usePagination } from '@/hooks'
|
||||
|
||||
import 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: '图片', 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 } =
|
||||
usePagination()
|
||||
|
||||
const editDialogRef = ref()
|
||||
getPageList()
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.imgmgt
|
||||
.getDataList({
|
||||
pageSize,
|
||||
current:current,
|
||||
type: 100,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
//筛选type的值100对应corporateHonor
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: t('pages.system.user.delTip'),
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.imgmgt.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
resolve()
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getPageList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
function onTableChange({ current, pageSize }) {
|
||||
paginationState.current = current
|
||||
paginationState.pageSize = pageSize
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
|
||||
await getPageList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
169
src/views/AboutY/importantEvents/components/Department.vue
Normal file
169
src/views/AboutY/importantEvents/components/Department.vue
Normal file
@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<a-card
|
||||
:body-style="{ height: 'calc(100% - 56px - 47px)', padding: 0 }"
|
||||
:style="{
|
||||
position: 'sticky',
|
||||
top: appStore.mainOffsetTop,
|
||||
height: appStore.mainHeight,
|
||||
}">
|
||||
<template #title>
|
||||
<a-input-search placeholder="搜索部门"></a-input-search>
|
||||
</template>
|
||||
<x-scrollbar class="pa-8-2">
|
||||
<a-spin :spinning="loading">
|
||||
<a-tree
|
||||
block-node
|
||||
:selected-keys="selectedKeys"
|
||||
:tree-data="listData"
|
||||
:field-names="{ key: 'id', children: 'children' }"
|
||||
@select="onSelect">
|
||||
<template #title="{ title }">
|
||||
<span class="ant-tree-title__name">{{ title }}</span>
|
||||
<span class="ant-tree-title__actions">
|
||||
<a-dropdown
|
||||
:trigger="['click']"
|
||||
@click.stop>
|
||||
<x-action-button>
|
||||
<more-outlined></more-outlined>
|
||||
</x-action-button>
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
添加子部门
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
编辑
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="handleDelete">删除</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</span>
|
||||
</template>
|
||||
</a-tree>
|
||||
<empty
|
||||
v-if="!listData.length"
|
||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"></empty>
|
||||
</a-spin>
|
||||
</x-scrollbar>
|
||||
<template #actions>
|
||||
<span @click="$refs.editDepartmentDialogRef.handleCreate()">
|
||||
<plus-outlined></plus-outlined>
|
||||
新建部门
|
||||
</span>
|
||||
</template>
|
||||
</a-card>
|
||||
|
||||
<edit-department-dialog
|
||||
ref="editDepartmentDialogRef"
|
||||
@ok="onOk"></edit-department-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useAppStore } from '@/store'
|
||||
import { ref, watch } from 'vue'
|
||||
import { usePagination } from '@/hooks'
|
||||
import apis from '@/apis'
|
||||
import { Empty, Modal, message } from 'ant-design-vue'
|
||||
import { config } from '@/config'
|
||||
import { head, get, find } from 'lodash-es'
|
||||
import { MoreOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
||||
import EditDepartmentDialog from './EditDepartmentDialog.vue'
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
|
||||
const appStore = useAppStore()
|
||||
const { listData, loading, showLoading, hideLoading } = usePagination()
|
||||
|
||||
const editDepartmentDialogRef = ref()
|
||||
const selectedKeys = ref([props.value])
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (val === selectedKeys.value?.[0]) return
|
||||
selectedKeys.value = [val]
|
||||
}
|
||||
)
|
||||
|
||||
getList()
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { code, data } = await apis.common.getPageList().catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === code) {
|
||||
const { records } = data
|
||||
listData.value = records
|
||||
if (listData.value.length) {
|
||||
selectedKeys.value = [get(head(listData.value), 'id')]
|
||||
trigger()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: '删除提示',
|
||||
content: '确认删除?',
|
||||
okText: '确认',
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
try {
|
||||
const { code } = await apis.common.del(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === code) {
|
||||
resolve()
|
||||
message.success('删除成功')
|
||||
await getList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function onSelect(keys) {
|
||||
if (!keys.length) return
|
||||
selectedKeys.value = keys
|
||||
trigger()
|
||||
}
|
||||
|
||||
async function onOk() {
|
||||
await getList()
|
||||
}
|
||||
|
||||
function trigger() {
|
||||
const value = head(selectedKeys.value)
|
||||
const record = find(listData.value, { id: value })
|
||||
emit('update:value', value)
|
||||
emit('change', record)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:open="modal.open"
|
||||
:title="modal.title"
|
||||
:width="480"
|
||||
:confirm-loading="modal.confirmLoading"
|
||||
:after-close="onAfterClose"
|
||||
:cancel-text="cancelText"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
:label-col="{ style: { width: '90px' } }">
|
||||
<a-form-item
|
||||
label="部门名称"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="上级部门"
|
||||
name="parent_id">
|
||||
<a-tree-select v-model:value="formData.parent_id"></a-tree-select>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="部门负责人"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
|
||||
const emit = defineEmits(['ok'])
|
||||
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
const cancelText = ref('取消')
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '新建部门',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: '编辑部门',
|
||||
})
|
||||
formRecord.value = record
|
||||
formData.value = cloneDeep(record)
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
}
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.common.create(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.common.update(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.code) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
cancelText.value = '取消'
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
431
src/views/productY/productCentre/components/EditDialog.vue
Normal file
431
src/views/productY/productCentre/components/EditDialog.vue
Normal file
@ -0,0 +1,431 @@
|
||||
<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-spin :spinning="spining">
|
||||
<a-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<a-card class="mb-8-2">
|
||||
<a-tabs v-model:activeKey="activeKey">
|
||||
<a-tab-pane key="1" tab="基本信息">
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'产品名称'" name="code">
|
||||
<a-input :placeholder="'请输入产品名称'" v-model:value="formData.code"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'产品类别'" name="categoryIDs">
|
||||
<!-- <a-tree-select v-model:value="formData.categoryIDs" :tree-data="categoryList"
|
||||
@change="handleTreeSelectChange" placeholder="请选择(只能选最后一级)"
|
||||
style="width: 100%" tree-default-expand-all/> -->
|
||||
<a-tree-select v-model:value="formData.categoryIDs" style="width: 100%" :tree-data="categoryList"
|
||||
tree-checkable allow-clear :show-checked-strategy="SHOW_PARENT"
|
||||
placeholder="Please select" tree-node-filter-prop="label" @change="handleChange"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'原料组成'" name="compose">
|
||||
<a-textarea :placeholder="'请输入原料组成'"
|
||||
v-model:value="formData.compose"></a-textarea>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'适用对象'" name="target">
|
||||
<a-input :placeholder="'请输入适用对象'" v-model:value="formData.target"></a-input>
|
||||
</a-form-item>
|
||||
|
||||
</a-col>
|
||||
|
||||
<a-col :span="12">
|
||||
<a-form-item :label="'产品排序'" name="sequence">
|
||||
<a-input-number v-model:value="formData.sequence" :placeholder="'请输入排序'"
|
||||
style="width: 100%;" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<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-form-item :label="'产品图片'">
|
||||
<gx-upload v-model="formData.mainImage" :fileNumber="2" />
|
||||
</a-form-item>
|
||||
|
||||
</a-row>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="2" tab="产品功能">
|
||||
<a-col :span="24">
|
||||
<a-form-item v-for="(item, index) in formData.feature" :key="index"
|
||||
:label="`产品功能特点 ${index + 1}`">
|
||||
<a-input v-model:value="item.label" placeholder="请输入功能特点标题" class="inputPhone" />
|
||||
<a-select v-model:value="item.data" mode="tags" :placeholder="'请输入功能特点,按回车区分不同特点'"
|
||||
:token-separators="[',']" style="width: 100%;" />
|
||||
<a-button danger @click="removeFeature(index)" size="small" style="margin-top: 8px">
|
||||
删除
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-button type="dashed" block @click="addFeature">
|
||||
新增产品功能特点
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
|
||||
</a-col>
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="3" tab="产品标准">
|
||||
<a-col :span="24">
|
||||
<a-form-item v-for="(item, index) in formData.standard" :key="index"
|
||||
:label="`产品标准 ${index + 1}`">
|
||||
<a-input v-model:value="item.label" placeholder="请输入标准名称" class="inputPhone" />
|
||||
<a-input v-model:value="item.fu_hoao" placeholder="请输入符号" class="inputPhone"
|
||||
style="margin-top: 8px" />
|
||||
<a-input v-model:value="item.val" placeholder="请输入标准值" class="inputPhone"
|
||||
style="margin-top: 8px" />
|
||||
<a-input v-model:value="item.prx" placeholder="请输入标准值单位" class="inputPhone"
|
||||
style="margin-top: 8px" />
|
||||
<a-button danger @click="removeStandard(index)" size="small"
|
||||
style="margin-top: 8px">
|
||||
删除
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item>
|
||||
<a-button type="dashed" block @click="addStandard">
|
||||
新增产品标准
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
|
||||
</a-col>
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
|
||||
</a-card>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import apis from '@/apis'
|
||||
import { useForm, useModal, useSpining } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import dayjs from 'dayjs'
|
||||
import {
|
||||
createProductCategory,
|
||||
createProductObj, createProductsItem,
|
||||
getProductCategory,
|
||||
getProductObj,
|
||||
getProductsItem, updateProductsItem,
|
||||
} from '@/apis/modules/products'
|
||||
import { spliceUrl } from '@/utils/util'
|
||||
const areaFormRef = ref()
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
const { spining, showSpining, hideSpining } = useSpining()
|
||||
const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
const rolesValue = ref([])
|
||||
const roles = ref([])
|
||||
const imgUrl = ref('')
|
||||
const categoryList = ref([])
|
||||
const targetList = ref([])
|
||||
const images = ref([])
|
||||
const contentImage = ref([])
|
||||
const childOpen = ref(false)
|
||||
const categoryIDs=['']
|
||||
const activeKey = ref('1')
|
||||
formRules.value = {
|
||||
title: { required: true, message: '请输入产品类别名称' },
|
||||
code: { required: true, message: '请输入产品名称' },
|
||||
categoryIDs: { required: true, message: '请选择产品类别', trigger: 'change' },
|
||||
compose: { required: false, message: '请选择产品适用对象'},
|
||||
feature: [{ required: true, message: '请输入产品功能特点', trigger: 'change' }],
|
||||
// feature: [{ required: true, message: '请输入产品功能特点' }],
|
||||
standard: [{ required: true, message: '请输入产品标准' }],
|
||||
images: [{ required: true, message: '请上传产品图片' }],
|
||||
mainImage: { required: true, message: '请上传产品图片' },
|
||||
contentImage: { required: false, message: '请上传产品内容图片' },
|
||||
sequence: [{ required: true, message: '请输入产品排序' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
|
||||
}
|
||||
|
||||
const initData = async () => {
|
||||
try {
|
||||
showSpining();
|
||||
const { success: prodSuccess, data: prodData } = await apis.categorys.getDataList({ pageSize: 999, page: 1 });
|
||||
if (config('http.code.success') === prodSuccess) {
|
||||
categoryList.value = prodData
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
message.error({ content: error.message });
|
||||
} finally {
|
||||
hideSpining();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '产品中心',
|
||||
})
|
||||
// 初始化所有字段
|
||||
formData.value = {
|
||||
title: '',
|
||||
categoryIDs: [],
|
||||
compose: '',
|
||||
target: '',
|
||||
feature: [{
|
||||
label: '功能特点',
|
||||
data: []
|
||||
}],
|
||||
standard: [{
|
||||
label: '',
|
||||
val: '',
|
||||
fu_hoao: '',
|
||||
prx: '',
|
||||
}],
|
||||
images: [''],
|
||||
sequence: null,
|
||||
status: 'enabled',
|
||||
}
|
||||
initData()
|
||||
}
|
||||
|
||||
//新建产品适用对象
|
||||
const childHandleObjOk = async () => {
|
||||
areaFormRef.value.validateFields().then(async (values) => {
|
||||
try {
|
||||
const params = { ...targetForm.value }
|
||||
const { success } = await apis.products.createProductObj(params)
|
||||
if (success) message.success('新增成功')
|
||||
childOpen.value = false
|
||||
targetForm.value = { targetName: '', status: 'enabled' }
|
||||
initData()
|
||||
} catch (error) {
|
||||
message.error(error.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
const handleCombinedOk = () => {
|
||||
childHandleOk();
|
||||
childHandleObjOk();
|
||||
};
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function handleEdit(record = {}) {
|
||||
initData()
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: t('pages.system.user.edit'),
|
||||
})
|
||||
const { data, success } = await apis.products.getProductsItem(record.id).catch()
|
||||
if (!success) {
|
||||
hideModal()
|
||||
return
|
||||
}
|
||||
formData.value = {
|
||||
...data,
|
||||
categoryIDs: data.categoryID,
|
||||
categoryRootID: data.categoryRootID,
|
||||
standard: data.standard || [{
|
||||
label: '',
|
||||
val: '',
|
||||
fu_hoao: '',
|
||||
prx: '',
|
||||
}],
|
||||
feature: data.feature || [{
|
||||
label: '功能特点',
|
||||
data: []
|
||||
}],
|
||||
// images:data.images || [''],
|
||||
mainImage: data.images ? data.images.map(item => config('http.apiBasic') + item) : [''],
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
console.log('编辑产品列表', formData.value)
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
categoryID: formData.value.categoryIDs,
|
||||
categoryRootID: formData.value.categoryRootID,
|
||||
standard: formData.value.standard ||
|
||||
[{
|
||||
label: '',
|
||||
val: '',
|
||||
fu_hoao: '',
|
||||
prx: '',
|
||||
}],
|
||||
feature: formData.value.feature,
|
||||
images: formData.value.mainImage ? formData.value.mainImage.map(item => spliceUrl(item)) : [''],
|
||||
}
|
||||
console.log(params)
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.products.createProductsItem(params).catch((error) => {
|
||||
throw new Error(error)
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.products.updateProductsItem(formData.value.id, params).catch(() => {
|
||||
throw new Error(error)
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
message.error({ content: error.message })
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
imgUrl.value = ''
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
|
||||
// 添加标准
|
||||
function addStandard() {
|
||||
formData.value.standard.push({ label: '', value: '' })
|
||||
}
|
||||
|
||||
// 删除标准
|
||||
function removeStandard(index) {
|
||||
if (formData.value.standard.length > 1) {
|
||||
formData.value.standard.splice(index, 1)
|
||||
}
|
||||
}
|
||||
// 添加标准
|
||||
function addFeature() {
|
||||
formData.value.feature.push({ label: '', value: '' })
|
||||
}
|
||||
|
||||
// 删除标准
|
||||
function removeFeature(index) {
|
||||
if (formData.value.feature.length > 1) {
|
||||
formData.value.feature.splice(index, 1)
|
||||
}
|
||||
}
|
||||
// 递归查找节点路径
|
||||
const findNodePath = (tree, value, path = []) => {
|
||||
for (const node of tree) {
|
||||
const currentPath = [...path, node.value];
|
||||
if (node.value === value) return currentPath;
|
||||
if (node.children) {
|
||||
const found = findNodePath(node.children, value, currentPath);
|
||||
if (found) return found;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
// 获取节点是否是叶子节点
|
||||
const isLeafNode = (id) => {
|
||||
const node = findNodeById(categoryList.value, id);
|
||||
if (node.children.length > 0) return false;
|
||||
else return true
|
||||
};
|
||||
//根据Id
|
||||
// 根据ID查找节点
|
||||
const findNodeById = (tree, value) => {
|
||||
for (const node of tree) {
|
||||
if (node.value == value) return node.value;
|
||||
if (node.children) {
|
||||
const found = findNodeById(node.children, value)
|
||||
if (found) return found.value;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
// 处理选择事件
|
||||
const handleTreeSelectChange = (value) => {
|
||||
// 验证是否叶子节点
|
||||
// if (!isLeafNode(value)) {
|
||||
// message.warning('只能选择最后一级节点');
|
||||
// formData.value.categoryID = null; // 清除非叶子选择
|
||||
// return;
|
||||
// }
|
||||
// if (!value) return;
|
||||
const pathIds = findNodePath(categoryList.value, value);
|
||||
if (pathIds) {
|
||||
console.log('选中的路径ID数组:', pathIds);
|
||||
// 实际使用中,此处可提交 pathIds 到后端或进行其他操作
|
||||
formData.value.categoryID = pathIds[1]
|
||||
formData.value.categoryRootID = pathIds[0]
|
||||
}
|
||||
};
|
||||
// 递归查找父节点 key 的函数
|
||||
const getParentKey = (key, tree) => {
|
||||
for (const node of tree) {
|
||||
if (node.children) {
|
||||
if (node.children.some(child => child.value === key)) {
|
||||
return node.value; // 返回直接父节点 key
|
||||
}
|
||||
const parentKey = getParentKey(key, node.children);
|
||||
if (parentKey) return parentKey;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// 处理选择变化
|
||||
const handleChange = (selectedKeys) => {
|
||||
if (selectedKeys.length > 0) {
|
||||
const lastSelectedKey = selectedKeys[selectedKeys.length - 1];
|
||||
const parentKey = getParentKey(lastSelectedKey, categoryList.value);
|
||||
|
||||
console.log('选中的父级值:', parentKey);
|
||||
formData.value.categoryRootID=parentKey
|
||||
// 使用父级值做其他操作...
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
250
src/views/productY/productCentre/index.vue
Normal file
250
src/views/productY/productCentre/index.vue
Normal file
@ -0,0 +1,250 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<!-- <a-col v-bind="colSpan">
|
||||
<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 label="产品名称" name="code">
|
||||
<a-input placeholder="请输入产品名称" v-model:value="searchFormData.code"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col v-bind="colSpan">
|
||||
<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-space>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
<a-row :gutter="8" :wrap="false">
|
||||
<a-col flex="auto">
|
||||
<a-card type="flex">
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
新增产品
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.dataIndex === 'title'">
|
||||
<a-tooltip :title="record.title">
|
||||
<div class="text-ellipsis">{{ record.title }}</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'categoryID'">
|
||||
<a-tooltip :title="record.categoryID">
|
||||
<div class="text-ellipsis">{{ record.categoryID }}</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'target'">
|
||||
<a-tooltip :title="record.target">
|
||||
<div class="text-ellipsis">{{ record.target }}</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'CategoryRootID'">
|
||||
<a-tooltip :title="record.CategoryRootID">
|
||||
<div class="text-ellipsis">{{ record.CategoryRootID }}</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="column.dataIndex === 'compose'">
|
||||
<a-tooltip :title="record.compose">
|
||||
<div class="text-ellipsis">{{ record.compose }}</div>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<template v-if="'mainImage' === column.dataIndex">
|
||||
<a-image :width="60" :alt="column.title" :src="config('http.apiBasic') + record.mainImage || $imageErr.imgErr" />
|
||||
</template>
|
||||
<template v-if="'contentImage' === column.dataIndex">
|
||||
<a-image :width="60" :alt="column.title" :src="config('http.apiBasic') + record.contentImage || $imageErr.imgErr" />
|
||||
</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>
|
||||
<x-action-button @click="handleDelete(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ref } from 'vue'
|
||||
import apis from '@/apis'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import { config } from '@/config'
|
||||
import { statusUserTypeEnum } from '@/enums/system'
|
||||
import { usePagination } from '@/hooks'
|
||||
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { delProductsItem, getProductsList } from '@/apis/modules/products'
|
||||
defineOptions({
|
||||
name: 'productCentre',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
{ title: '产品名称', dataIndex: 'code', width: 120, ellipsis:true},
|
||||
{ title: '产品类别', dataIndex: 'categoryRootName', key: 'categoryRootName', width: 120 },
|
||||
{ title: '适用对象', dataIndex: 'target', width: 120 },
|
||||
{ title: '原料组成', dataIndex: 'compose', key: 'compose', width: 120 },
|
||||
// {
|
||||
// title: '产品标准',
|
||||
// dataIndex: 'standard',
|
||||
// width: 120,
|
||||
// align: 'center',
|
||||
// customRender: ({ text }) => Array.isArray(text)
|
||||
// ? text.map(item => `${item.label}: ${item.fu_hoao}${item.val}${item.prx}`).join(', ')
|
||||
// : ''
|
||||
// },
|
||||
// {
|
||||
// title: '产品图片',
|
||||
// dataIndex: 'mainImage',
|
||||
// width: 120,
|
||||
// align: 'center',
|
||||
// },
|
||||
// {
|
||||
// title: '产品内容图片',
|
||||
// dataIndex: 'contentImage',
|
||||
// width: 120,
|
||||
// align: 'center',
|
||||
// },
|
||||
|
||||
{ title: '产品排序', dataIndex: 'sequence', width: 120, align: 'center' },
|
||||
{ title: '产品状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||
]
|
||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||
usePagination()
|
||||
|
||||
const editDialogRef = ref()
|
||||
getPageList()
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.products
|
||||
.getProductsList({
|
||||
pageSize,
|
||||
current:current,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data.map(item => ({
|
||||
...item,
|
||||
}))
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: t('pages.system.user.delTip'),
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.products.delProductsItem(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
resolve()
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getPageList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
function onTableChange({ current, pageSize }) {
|
||||
paginationState.current = current
|
||||
paginationState.pageSize = pageSize
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
await getPageList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
146
src/views/productY/productClassify/components/EditDialog.vue
Normal file
146
src/views/productY/productClassify/components/EditDialog.vue
Normal file
@ -0,0 +1,146 @@
|
||||
<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-spin :spinning="spining">
|
||||
<a-form ref="formRef" :model="formData" :rules="formRules">
|
||||
<a-card class="mb-8-2">
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'父级分类'" name="parentID">
|
||||
<a-tree-select v-model:value="formData.parentID" show-search style="width: 100%"
|
||||
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" placeholder="请选择"
|
||||
allow-clear tree-default-expand-all :tree-data="treeData"
|
||||
tree-node-filter-prop="label">
|
||||
</a-tree-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'产品分类'" name="label">
|
||||
<a-input :placeholder="'请输入产品分类名称'" v-model:value="formData.label"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref, onBeforeMount } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import apis from '@/apis'
|
||||
import { useForm, useModal, useSpining } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
|
||||
import { spliceUrl } from '@/utils/util'
|
||||
const areaFormRef = ref()
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
const { spining, showSpining, hideSpining } = useSpining()
|
||||
const cancelText = ref(t('button.cancel'))
|
||||
const okText = ref(t('button.confirm'))
|
||||
const treeData=ref([])
|
||||
formRules.value = {
|
||||
label: { required: true, message: '请输入产品类别名称' },
|
||||
}
|
||||
|
||||
|
||||
const initData = async () => {
|
||||
const { success, data, total } = await apis.categorys
|
||||
.getDataList({
|
||||
pageSize:99,
|
||||
page: 1,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
treeData.value = data.map(item => ({
|
||||
...item
|
||||
}))
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '产品分类',
|
||||
})
|
||||
// 初始化所有字段
|
||||
initData()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
parentID:formData.value.parentID?formData.value.parentID:0
|
||||
}
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.categorys.createProductsItem(params).catch((error) => {
|
||||
throw new Error(error)
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.products.updateProductsItem(formData.value.id, params).catch(() => {
|
||||
throw new Error(error)
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
message.error({ content: error.message })
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
})
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
154
src/views/productY/productClassify/index.vue
Normal file
154
src/views/productY/productClassify/index.vue
Normal file
@ -0,0 +1,154 @@
|
||||
<template>
|
||||
<a-row :gutter="8" :wrap="false">
|
||||
<a-col flex="auto">
|
||||
<a-card type="flex">
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
新增分类
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||
:pagination="paginationState" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<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="handleDelete(record.value)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ref } from 'vue'
|
||||
import apis from '@/apis'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import { config } from '@/config'
|
||||
import { statusUserTypeEnum } from '@/enums/system'
|
||||
import { usePagination } from '@/hooks'
|
||||
|
||||
import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { delProductsItem, getProductsList } from '@/apis/modules/products'
|
||||
defineOptions({
|
||||
name: 'productClassify',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
{ title: '分类名称', dataIndex: 'label' },
|
||||
// { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||
]
|
||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
||||
usePagination()
|
||||
|
||||
const editDialogRef = ref()
|
||||
getPageList()
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.categorys
|
||||
.getDataList({
|
||||
pageSize,
|
||||
current:current,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data.map(item => ({
|
||||
...item,
|
||||
key:item.value
|
||||
}))
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete(value) {
|
||||
Modal.confirm({
|
||||
title: '确定删除该分类吗',
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.categorys.delProductsItem(value).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
resolve()
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getPageList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
function onTableChange({ current, pageSize }) {
|
||||
paginationState.current = current
|
||||
paginationState.pageSize = pageSize
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
await getPageList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
169
src/views/talentCenter/environment/components/Department.vue
Normal file
169
src/views/talentCenter/environment/components/Department.vue
Normal file
@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<a-card
|
||||
:body-style="{ height: 'calc(100% - 56px - 47px)', padding: 0 }"
|
||||
:style="{
|
||||
position: 'sticky',
|
||||
top: appStore.mainOffsetTop,
|
||||
height: appStore.mainHeight,
|
||||
}">
|
||||
<template #title>
|
||||
<a-input-search placeholder="搜索部门"></a-input-search>
|
||||
</template>
|
||||
<x-scrollbar class="pa-8-2">
|
||||
<a-spin :spinning="loading">
|
||||
<a-tree
|
||||
block-node
|
||||
:selected-keys="selectedKeys"
|
||||
:tree-data="listData"
|
||||
:field-names="{ key: 'id', children: 'children' }"
|
||||
@select="onSelect">
|
||||
<template #title="{ title }">
|
||||
<span class="ant-tree-title__name">{{ title }}</span>
|
||||
<span class="ant-tree-title__actions">
|
||||
<a-dropdown
|
||||
:trigger="['click']"
|
||||
@click.stop>
|
||||
<x-action-button>
|
||||
<more-outlined></more-outlined>
|
||||
</x-action-button>
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
添加子部门
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
编辑
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="handleDelete">删除</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</span>
|
||||
</template>
|
||||
</a-tree>
|
||||
<empty
|
||||
v-if="!listData.length"
|
||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"></empty>
|
||||
</a-spin>
|
||||
</x-scrollbar>
|
||||
<template #actions>
|
||||
<span @click="$refs.editDepartmentDialogRef.handleCreate()">
|
||||
<plus-outlined></plus-outlined>
|
||||
新建部门
|
||||
</span>
|
||||
</template>
|
||||
</a-card>
|
||||
|
||||
<edit-department-dialog
|
||||
ref="editDepartmentDialogRef"
|
||||
@ok="onOk"></edit-department-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useAppStore } from '@/store'
|
||||
import { ref, watch } from 'vue'
|
||||
import { usePagination } from '@/hooks'
|
||||
import apis from '@/apis'
|
||||
import { Empty, Modal, message } from 'ant-design-vue'
|
||||
import { config } from '@/config'
|
||||
import { head, get, find } from 'lodash-es'
|
||||
import { MoreOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
||||
import EditDepartmentDialog from './EditDepartmentDialog.vue'
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
|
||||
const appStore = useAppStore()
|
||||
const { listData, loading, showLoading, hideLoading } = usePagination()
|
||||
|
||||
const editDepartmentDialogRef = ref()
|
||||
const selectedKeys = ref([props.value])
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (val === selectedKeys.value?.[0]) return
|
||||
selectedKeys.value = [val]
|
||||
}
|
||||
)
|
||||
|
||||
getList()
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { code, data } = await apis.common.getPageList().catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === code) {
|
||||
const { records } = data
|
||||
listData.value = records
|
||||
if (listData.value.length) {
|
||||
selectedKeys.value = [get(head(listData.value), 'id')]
|
||||
trigger()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: '删除提示',
|
||||
content: '确认删除?',
|
||||
okText: '确认',
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
try {
|
||||
const { code } = await apis.common.del(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === code) {
|
||||
resolve()
|
||||
message.success('删除成功')
|
||||
await getList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function onSelect(keys) {
|
||||
if (!keys.length) return
|
||||
selectedKeys.value = keys
|
||||
trigger()
|
||||
}
|
||||
|
||||
async function onOk() {
|
||||
await getList()
|
||||
}
|
||||
|
||||
function trigger() {
|
||||
const value = head(selectedKeys.value)
|
||||
const record = find(listData.value, { id: value })
|
||||
emit('update:value', value)
|
||||
emit('change', record)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:open="modal.open"
|
||||
:title="modal.title"
|
||||
:width="480"
|
||||
:confirm-loading="modal.confirmLoading"
|
||||
:after-close="onAfterClose"
|
||||
:cancel-text="cancelText"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
:label-col="{ style: { width: '90px' } }">
|
||||
<a-form-item
|
||||
label="部门名称"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="上级部门"
|
||||
name="parent_id">
|
||||
<a-tree-select v-model:value="formData.parent_id"></a-tree-select>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="部门负责人"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
|
||||
const emit = defineEmits(['ok'])
|
||||
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
const cancelText = ref('取消')
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '新建部门',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: '编辑部门',
|
||||
})
|
||||
formRecord.value = record
|
||||
formData.value = cloneDeep(record)
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
}
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.common.create(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.common.update(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.code) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
cancelText.value = '取消'
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
197
src/views/talentCenter/environment/components/EditDialog.vue
Normal file
197
src/views/talentCenter/environment/components/EditDialog.vue
Normal file
@ -0,0 +1,197 @@
|
||||
<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">
|
||||
<a-card class="mb-8-2">
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'名称'" name="name">
|
||||
<a-input :placeholder="'请输入名称'" v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'顺序'" name="sequence">
|
||||
<a-input-number :placeholder="'请输入顺序'" v-model:value="formData.sequence"></a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'状态'" name="status">
|
||||
<a-radio-group v-model:value="formData.status" :options="[
|
||||
{ label: '启用', value: 'enabled' },
|
||||
{ label: '停用', value: 'disabled' },
|
||||
]"></a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'图片'" name="img">
|
||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
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()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
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: '请输入名称' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
const imgChange = (value) => {
|
||||
formData.value.img = value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
// 80对应about
|
||||
title: '添加',
|
||||
})
|
||||
formData.value.status = 'enabled'
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: t('pages.system.user.edit'),
|
||||
})
|
||||
const { data, success } = await apis.imgmgt.getMenu(record.id).catch()
|
||||
if (!success) {
|
||||
hideModal()
|
||||
return
|
||||
}
|
||||
formData.value = { ...data }
|
||||
formData.value.pushAt=dayjs(data.pushAt)
|
||||
console.log(formData.value)
|
||||
img.value = config('http.apiBasic') + data.img
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
if (!formData.value.img) return message.error('请上传图片');
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
console.log(values)
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
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.imgmgt.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 对权限组 过数据格式
|
||||
*/
|
||||
function formatArr(data, type = '') {
|
||||
const rolesArr = []
|
||||
data.forEach((item) => {
|
||||
roles.value.forEach((r) => {
|
||||
if (type === 'edit') {
|
||||
if (item.role_id === r.value) {
|
||||
rolesArr.push({
|
||||
value: item.role_id,
|
||||
label: r.label,
|
||||
})
|
||||
return
|
||||
}
|
||||
} else if (r.value === item) {
|
||||
rolesArr.push({
|
||||
role_id: item,
|
||||
role_name: r.label,
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
})
|
||||
return rolesArr
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
img.value = ''
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
202
src/views/talentCenter/environment/index.vue
Normal file
202
src/views/talentCenter/environment/index.vue
Normal file
@ -0,0 +1,202 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<a-col v-bind="colSpan">
|
||||
<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 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-space>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
<a-row :gutter="8" :wrap="false">
|
||||
<a-col flex="auto">
|
||||
<a-card type="flex">
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
新增
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'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="'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>
|
||||
<x-action-button @click="handleDelete(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ref } from 'vue'
|
||||
import apis from '@/apis'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import { config } from '@/config'
|
||||
import { statusUserTypeEnum } from '@/enums/system'
|
||||
import { usePagination } from '@/hooks'
|
||||
|
||||
import 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: 'environment',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
{ 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 } =
|
||||
usePagination()
|
||||
|
||||
const editDialogRef = ref()
|
||||
getPageList()
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.imgmgt
|
||||
.getDataList({
|
||||
pageSize,
|
||||
current:current,
|
||||
type: 90,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
//筛选type的值90对应talentCenter
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: t('pages.system.user.delTip'),
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.imgmgt.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
resolve()
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getPageList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
function onTableChange({ current, pageSize }) {
|
||||
paginationState.current = current
|
||||
paginationState.pageSize = pageSize
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
|
||||
await getPageList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@ -150,7 +150,7 @@ import EditDialog from './components/EditDialog.vue'
|
||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
defineOptions({
|
||||
name: 'homeBanner',
|
||||
name: 'recruitment',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
169
src/views/talentCenter/teamStyle/components/Department.vue
Normal file
169
src/views/talentCenter/teamStyle/components/Department.vue
Normal file
@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<a-card
|
||||
:body-style="{ height: 'calc(100% - 56px - 47px)', padding: 0 }"
|
||||
:style="{
|
||||
position: 'sticky',
|
||||
top: appStore.mainOffsetTop,
|
||||
height: appStore.mainHeight,
|
||||
}">
|
||||
<template #title>
|
||||
<a-input-search placeholder="搜索部门"></a-input-search>
|
||||
</template>
|
||||
<x-scrollbar class="pa-8-2">
|
||||
<a-spin :spinning="loading">
|
||||
<a-tree
|
||||
block-node
|
||||
:selected-keys="selectedKeys"
|
||||
:tree-data="listData"
|
||||
:field-names="{ key: 'id', children: 'children' }"
|
||||
@select="onSelect">
|
||||
<template #title="{ title }">
|
||||
<span class="ant-tree-title__name">{{ title }}</span>
|
||||
<span class="ant-tree-title__actions">
|
||||
<a-dropdown
|
||||
:trigger="['click']"
|
||||
@click.stop>
|
||||
<x-action-button>
|
||||
<more-outlined></more-outlined>
|
||||
</x-action-button>
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
添加子部门
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
编辑
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="handleDelete">删除</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</span>
|
||||
</template>
|
||||
</a-tree>
|
||||
<empty
|
||||
v-if="!listData.length"
|
||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"></empty>
|
||||
</a-spin>
|
||||
</x-scrollbar>
|
||||
<template #actions>
|
||||
<span @click="$refs.editDepartmentDialogRef.handleCreate()">
|
||||
<plus-outlined></plus-outlined>
|
||||
新建部门
|
||||
</span>
|
||||
</template>
|
||||
</a-card>
|
||||
|
||||
<edit-department-dialog
|
||||
ref="editDepartmentDialogRef"
|
||||
@ok="onOk"></edit-department-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useAppStore } from '@/store'
|
||||
import { ref, watch } from 'vue'
|
||||
import { usePagination } from '@/hooks'
|
||||
import apis from '@/apis'
|
||||
import { Empty, Modal, message } from 'ant-design-vue'
|
||||
import { config } from '@/config'
|
||||
import { head, get, find } from 'lodash-es'
|
||||
import { MoreOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
||||
import EditDepartmentDialog from './EditDepartmentDialog.vue'
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
|
||||
const appStore = useAppStore()
|
||||
const { listData, loading, showLoading, hideLoading } = usePagination()
|
||||
|
||||
const editDepartmentDialogRef = ref()
|
||||
const selectedKeys = ref([props.value])
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (val === selectedKeys.value?.[0]) return
|
||||
selectedKeys.value = [val]
|
||||
}
|
||||
)
|
||||
|
||||
getList()
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { code, data } = await apis.common.getPageList().catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === code) {
|
||||
const { records } = data
|
||||
listData.value = records
|
||||
if (listData.value.length) {
|
||||
selectedKeys.value = [get(head(listData.value), 'id')]
|
||||
trigger()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: '删除提示',
|
||||
content: '确认删除?',
|
||||
okText: '确认',
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
try {
|
||||
const { code } = await apis.common.del(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === code) {
|
||||
resolve()
|
||||
message.success('删除成功')
|
||||
await getList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function onSelect(keys) {
|
||||
if (!keys.length) return
|
||||
selectedKeys.value = keys
|
||||
trigger()
|
||||
}
|
||||
|
||||
async function onOk() {
|
||||
await getList()
|
||||
}
|
||||
|
||||
function trigger() {
|
||||
const value = head(selectedKeys.value)
|
||||
const record = find(listData.value, { id: value })
|
||||
emit('update:value', value)
|
||||
emit('change', record)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:open="modal.open"
|
||||
:title="modal.title"
|
||||
:width="480"
|
||||
:confirm-loading="modal.confirmLoading"
|
||||
:after-close="onAfterClose"
|
||||
:cancel-text="cancelText"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
:label-col="{ style: { width: '90px' } }">
|
||||
<a-form-item
|
||||
label="部门名称"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="上级部门"
|
||||
name="parent_id">
|
||||
<a-tree-select v-model:value="formData.parent_id"></a-tree-select>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="部门负责人"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
|
||||
const emit = defineEmits(['ok'])
|
||||
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
const cancelText = ref('取消')
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '新建部门',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: '编辑部门',
|
||||
})
|
||||
formRecord.value = record
|
||||
formData.value = cloneDeep(record)
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
}
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.common.create(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.common.update(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.code) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
cancelText.value = '取消'
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
197
src/views/talentCenter/teamStyle/components/EditDialog.vue
Normal file
197
src/views/talentCenter/teamStyle/components/EditDialog.vue
Normal file
@ -0,0 +1,197 @@
|
||||
<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">
|
||||
<a-card class="mb-8-2">
|
||||
<a-row :gutter="12">
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'名称'" name="name">
|
||||
<a-input :placeholder="'请输入名称'" v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'顺序'" name="sequence">
|
||||
<a-input-number :placeholder="'请输入顺序'" v-model:value="formData.sequence"></a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'状态'" name="status">
|
||||
<a-radio-group v-model:value="formData.status" :options="[
|
||||
{ label: '启用', value: 'enabled' },
|
||||
{ label: '停用', value: 'disabled' },
|
||||
]"></a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'图片'" name="img">
|
||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
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()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
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: '请输入名称' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
const imgChange = (value) => {
|
||||
formData.value.img = value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
// 80对应about
|
||||
title: '添加',
|
||||
})
|
||||
formData.value.status = 'enabled'
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: t('pages.system.user.edit'),
|
||||
})
|
||||
const { data, success } = await apis.imgmgt.getMenu(record.id).catch()
|
||||
if (!success) {
|
||||
hideModal()
|
||||
return
|
||||
}
|
||||
formData.value = { ...data }
|
||||
formData.value.pushAt=dayjs(data.pushAt)
|
||||
console.log(formData.value)
|
||||
img.value = config('http.apiBasic') + data.img
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
if (!formData.value.img) return message.error('请上传图片');
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
console.log(values)
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
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.imgmgt.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
// result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
result = await apis.imgmgt.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 对权限组 过数据格式
|
||||
*/
|
||||
function formatArr(data, type = '') {
|
||||
const rolesArr = []
|
||||
data.forEach((item) => {
|
||||
roles.value.forEach((r) => {
|
||||
if (type === 'edit') {
|
||||
if (item.role_id === r.value) {
|
||||
rolesArr.push({
|
||||
value: item.role_id,
|
||||
label: r.label,
|
||||
})
|
||||
return
|
||||
}
|
||||
} else if (r.value === item) {
|
||||
rolesArr.push({
|
||||
role_id: item,
|
||||
role_name: r.label,
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
})
|
||||
return rolesArr
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
img.value = ''
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
202
src/views/talentCenter/teamStyle/index.vue
Normal file
202
src/views/talentCenter/teamStyle/index.vue
Normal file
@ -0,0 +1,202 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<a-col v-bind="colSpan">
|
||||
<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 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-space>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
<a-row :gutter="8" :wrap="false">
|
||||
<a-col flex="auto">
|
||||
<a-card type="flex">
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
新增
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'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="'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>
|
||||
<x-action-button @click="handleDelete(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { ref } from 'vue'
|
||||
import apis from '@/apis'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import { config } from '@/config'
|
||||
import { statusUserTypeEnum } from '@/enums/system'
|
||||
import { usePagination } from '@/hooks'
|
||||
|
||||
import 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: '图片', 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 } =
|
||||
usePagination()
|
||||
|
||||
const editDialogRef = ref()
|
||||
getPageList()
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.imgmgt
|
||||
.getDataList({
|
||||
pageSize,
|
||||
current:current,
|
||||
type: 70,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
//筛选type的值90对应talentCenter
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: t('pages.system.user.delTip'),
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.imgmgt.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
resolve()
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getPageList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
function onTableChange({ current, pageSize }) {
|
||||
paginationState.current = current
|
||||
paginationState.pageSize = pageSize
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
|
||||
await getPageList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
169
src/views/technologyCenter/team/components/Department.vue
Normal file
169
src/views/technologyCenter/team/components/Department.vue
Normal file
@ -0,0 +1,169 @@
|
||||
<template>
|
||||
<a-card
|
||||
:body-style="{ height: 'calc(100% - 56px - 47px)', padding: 0 }"
|
||||
:style="{
|
||||
position: 'sticky',
|
||||
top: appStore.mainOffsetTop,
|
||||
height: appStore.mainHeight,
|
||||
}">
|
||||
<template #title>
|
||||
<a-input-search placeholder="搜索部门"></a-input-search>
|
||||
</template>
|
||||
<x-scrollbar class="pa-8-2">
|
||||
<a-spin :spinning="loading">
|
||||
<a-tree
|
||||
block-node
|
||||
:selected-keys="selectedKeys"
|
||||
:tree-data="listData"
|
||||
:field-names="{ key: 'id', children: 'children' }"
|
||||
@select="onSelect">
|
||||
<template #title="{ title }">
|
||||
<span class="ant-tree-title__name">{{ title }}</span>
|
||||
<span class="ant-tree-title__actions">
|
||||
<a-dropdown
|
||||
:trigger="['click']"
|
||||
@click.stop>
|
||||
<x-action-button>
|
||||
<more-outlined></more-outlined>
|
||||
</x-action-button>
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
添加子部门
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="$refs.editDepartmentDialogRef.handleEdit()">
|
||||
编辑
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="handleDelete">删除</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
</a-dropdown>
|
||||
</span>
|
||||
</template>
|
||||
</a-tree>
|
||||
<empty
|
||||
v-if="!listData.length"
|
||||
:image="Empty.PRESENTED_IMAGE_SIMPLE"></empty>
|
||||
</a-spin>
|
||||
</x-scrollbar>
|
||||
<template #actions>
|
||||
<span @click="$refs.editDepartmentDialogRef.handleCreate()">
|
||||
<plus-outlined></plus-outlined>
|
||||
新建部门
|
||||
</span>
|
||||
</template>
|
||||
</a-card>
|
||||
|
||||
<edit-department-dialog
|
||||
ref="editDepartmentDialogRef"
|
||||
@ok="onOk"></edit-department-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { useAppStore } from '@/store'
|
||||
import { ref, watch } from 'vue'
|
||||
import { usePagination } from '@/hooks'
|
||||
import apis from '@/apis'
|
||||
import { Empty, Modal, message } from 'ant-design-vue'
|
||||
import { config } from '@/config'
|
||||
import { head, get, find } from 'lodash-es'
|
||||
import { MoreOutlined, PlusOutlined } from '@ant-design/icons-vue'
|
||||
import EditDepartmentDialog from './EditDepartmentDialog.vue'
|
||||
|
||||
const props = defineProps({
|
||||
value: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits(['change', 'update:value'])
|
||||
|
||||
const appStore = useAppStore()
|
||||
const { listData, loading, showLoading, hideLoading } = usePagination()
|
||||
|
||||
const editDepartmentDialogRef = ref()
|
||||
const selectedKeys = ref([props.value])
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (val === selectedKeys.value?.[0]) return
|
||||
selectedKeys.value = [val]
|
||||
}
|
||||
)
|
||||
|
||||
getList()
|
||||
|
||||
/**
|
||||
* 获取列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { code, data } = await apis.common.getPageList().catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === code) {
|
||||
const { records } = data
|
||||
listData.value = records
|
||||
if (listData.value.length) {
|
||||
selectedKeys.value = [get(head(listData.value), 'id')]
|
||||
trigger()
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: '删除提示',
|
||||
content: '确认删除?',
|
||||
okText: '确认',
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
;(async () => {
|
||||
try {
|
||||
const { code } = await apis.common.del(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === code) {
|
||||
resolve()
|
||||
message.success('删除成功')
|
||||
await getList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
function onSelect(keys) {
|
||||
if (!keys.length) return
|
||||
selectedKeys.value = keys
|
||||
trigger()
|
||||
}
|
||||
|
||||
async function onOk() {
|
||||
await getList()
|
||||
}
|
||||
|
||||
function trigger() {
|
||||
const value = head(selectedKeys.value)
|
||||
const record = find(listData.value, { id: value })
|
||||
emit('update:value', value)
|
||||
emit('change', record)
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<a-modal
|
||||
:open="modal.open"
|
||||
:title="modal.title"
|
||||
:width="480"
|
||||
:confirm-loading="modal.confirmLoading"
|
||||
:after-close="onAfterClose"
|
||||
:cancel-text="cancelText"
|
||||
@ok="handleOk"
|
||||
@cancel="handleCancel">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
:label-col="{ style: { width: '90px' } }">
|
||||
<a-form-item
|
||||
label="部门名称"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="上级部门"
|
||||
name="parent_id">
|
||||
<a-tree-select v-model:value="formData.parent_id"></a-tree-select>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="部门负责人"
|
||||
name="name">
|
||||
<a-input v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
import apis from '@/apis'
|
||||
import { useForm, useModal } from '@/hooks'
|
||||
|
||||
const emit = defineEmits(['ok'])
|
||||
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
const cancelText = ref('取消')
|
||||
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
title: '新建部门',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
title: '编辑部门',
|
||||
})
|
||||
formRecord.value = record
|
||||
formData.value = cloneDeep(record)
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
formRef.value
|
||||
.validateFields()
|
||||
.then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
}
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.common.create(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.common.update(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.code) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
cancelText.value = '取消'
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
218
src/views/technologyCenter/team/components/EditDialog.vue
Normal file
218
src/views/technologyCenter/team/components/EditDialog.vue
Normal file
@ -0,0 +1,218 @@
|
||||
<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">
|
||||
<a-card class="mb-8-2">
|
||||
<a-row :gutter="12">
|
||||
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'姓名'" name="name">
|
||||
<a-input :placeholder="'请输入姓名'" v-model:value="formData.name"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<!-- <a-col :span="24">-->
|
||||
<!-- <a-form-item :label="'人物描述'" name="rank">-->
|
||||
<!-- <a-input :placeholder="'请输入人物描述内容'" v-model:value="formData.rank"></a-input>-->
|
||||
<!-- </a-form-item>-->
|
||||
<!-- </a-col>-->
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'研究领域'" name="area">
|
||||
<a-input :placeholder="'请输入研究领域内容'" v-model:value="formData.area"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'人物简介'">
|
||||
<a-select
|
||||
v-model:value="formData.rank"
|
||||
mode="tags"
|
||||
:placeholder="'请输入研究领域,按回车分隔'"
|
||||
:token-separators="[',']"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'顺序'" name="sequence">
|
||||
<a-input-number :placeholder="'请输入顺序'" v-model:value="formData.sequence"></a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'状态'" name="status">
|
||||
<a-radio-group v-model:value="formData.status" :options="[
|
||||
{ label: '启用', value: 'enabled' },
|
||||
{ label: '停用', value: 'disabled' },
|
||||
]"></a-radio-group>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'图片'" name="img">
|
||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-card>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import { ref } from 'vue'
|
||||
import { config } from '@/config'
|
||||
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/team'
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
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: '请输入名称' },
|
||||
rank: { required: true, message: '请输入人物简介' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
/**
|
||||
* select 选择框
|
||||
*/
|
||||
const handleChange = (value) => {
|
||||
rolesValue.value = value
|
||||
}
|
||||
const imgChange = (value) => {
|
||||
formData.value.img = value
|
||||
}
|
||||
/**
|
||||
* 新建
|
||||
*/
|
||||
function handleCreate() {
|
||||
showModal({
|
||||
type: 'create',
|
||||
// 80对应about
|
||||
title: '添加',
|
||||
})
|
||||
formData.value.status = 'enabled'
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
// 80对应about
|
||||
title: t('pages.system.user.edit'),
|
||||
})
|
||||
const { data, success } = await apis.team.getMenu(record.id).catch()
|
||||
if (!success) {
|
||||
hideModal()
|
||||
return
|
||||
}
|
||||
formData.value = { ...data }
|
||||
formData.value.pushAt = dayjs(data.pushAt)
|
||||
console.log(formData.value)
|
||||
img.value = config('http.apiBasic') + data.img
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
function handleOk() {
|
||||
if (!formData.value.img) return message.error('请上传图片');
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
console.log(values)
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
...values,
|
||||
img: formData.value.img,
|
||||
rank: formData.value.rank,
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.team.createMenu(params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.team.updateMenu(formData.value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
break
|
||||
}
|
||||
hideLoading()
|
||||
if (config('http.code.success') === result?.success) {
|
||||
hideModal()
|
||||
emit('ok')
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 对权限组 过数据格式
|
||||
*/
|
||||
function formatArr(data, type = '') {
|
||||
const rolesArr = []
|
||||
data.forEach((item) => {
|
||||
roles.value.forEach((r) => {
|
||||
if (type === 'edit') {
|
||||
if (item.role_id === r.value) {
|
||||
rolesArr.push({
|
||||
value: item.role_id,
|
||||
label: r.label,
|
||||
})
|
||||
return
|
||||
}
|
||||
} else if (r.value === item) {
|
||||
rolesArr.push({
|
||||
role_id: item,
|
||||
role_name: r.label,
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
})
|
||||
return rolesArr
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
function handleCancel() {
|
||||
img.value = ''
|
||||
hideModal()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
*/
|
||||
function onAfterClose() {
|
||||
resetForm()
|
||||
hideLoading()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
226
src/views/technologyCenter/team/index.vue
Normal file
226
src/views/technologyCenter/team/index.vue
Normal file
@ -0,0 +1,226 @@
|
||||
<template>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form :label-col="{ style: { width: '40px' } }" :model="searchFormData" layout="inline">
|
||||
<a-row :gutter="gutter">
|
||||
<a-col v-bind="colSpan">
|
||||
<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 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-space>
|
||||
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||
<a-button ghost type="primary" @click="handleSearch">
|
||||
{{ $t('button.search') }}
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
<a-row :gutter="8" :wrap="false">
|
||||
<a-col flex="auto">
|
||||
<a-card type="flex">
|
||||
<x-action-bar class="mb-8-2">
|
||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
||||
<template #icon>
|
||||
<plus-outlined></plus-outlined>
|
||||
</template>
|
||||
新增
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'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="column.dataIndex === 'rank'">-->
|
||||
<!-- <a-tooltip :title="record.rank">-->
|
||||
<!-- <span>{{ record.rank }}</span>-->
|
||||
<!-- </a-tooltip>-->
|
||||
<!-- </template>-->
|
||||
<template v-if="column.dataIndex === 'rank'">
|
||||
<div>
|
||||
<a-tag
|
||||
v-for="(item, index) in record.rank"
|
||||
:key="index"
|
||||
color="blue"
|
||||
>
|
||||
{{ item }}
|
||||
</a-tag>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
<template v-if="column.dataIndex === 'area'">
|
||||
<a-tooltip :title="record.area">
|
||||
<span>{{ record.area }}</span>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
|
||||
<template v-if="'status' === column.dataIndex">
|
||||
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
|
||||
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
|
||||
</template>
|
||||
<template v-if="'action' === column.key">
|
||||
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||
<a-tooltip>
|
||||
<template #title> {{ $t('pages.system.user.edit') }}</template>
|
||||
<edit-outlined /> </a-tooltip></x-action-button>
|
||||
<x-action-button @click="handleDelete(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-card>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { computed } from 'vue';
|
||||
import { ref } from 'vue'
|
||||
import apis from '@/apis'
|
||||
import { formatUtcDateTime } from '@/utils/util'
|
||||
import { config } from '@/config'
|
||||
import { statusUserTypeEnum } from '@/enums/system'
|
||||
import { usePagination } from '@/hooks'
|
||||
|
||||
import 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/team'
|
||||
defineOptions({
|
||||
name: 'team',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
{ title: '图片', dataIndex: 'img', width: 100, align: 'center' },
|
||||
{ title: '名称', dataIndex: 'name', key: 'name' },
|
||||
{ title: '人物描述', dataIndex: 'rank', key: 'rank' },
|
||||
{ title: '研究领域', dataIndex: 'area', key: 'area' },
|
||||
{ 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 } =
|
||||
usePagination()
|
||||
|
||||
const editDialogRef = ref()
|
||||
getPageList()
|
||||
/**
|
||||
* 获取用户列表
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const { pageSize, current } = paginationState
|
||||
const { success, data, total } = await apis.team
|
||||
.getDataList({
|
||||
pageSize,
|
||||
current:current,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
hideLoading()
|
||||
if (config('http.code.success') === success) {
|
||||
listData.value = data
|
||||
paginationState.total = total
|
||||
}
|
||||
} catch (error) {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function handleDelete({ id }) {
|
||||
Modal.confirm({
|
||||
title: t('pages.system.user.delTip'),
|
||||
content: t('button.confirm'),
|
||||
okText: t('button.confirm'),
|
||||
onOk: () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
; (async () => {
|
||||
try {
|
||||
const { success } = await apis.team.delMenu(id).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
resolve()
|
||||
message.success(t('component.message.success.delete'))
|
||||
await getPageList()
|
||||
}
|
||||
} catch (error) {
|
||||
reject()
|
||||
}
|
||||
})()
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
function onTableChange({ current, pageSize }) {
|
||||
paginationState.current = current
|
||||
paginationState.pageSize = pageSize
|
||||
getPageList()
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
*/
|
||||
function handleSearch() {
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function handleResetSearch() {
|
||||
searchFormData.value = {}
|
||||
resetPagination()
|
||||
getPageList()
|
||||
}
|
||||
/**
|
||||
* 编辑完成
|
||||
*/
|
||||
async function onOk() {
|
||||
await getPageList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
Loading…
x
Reference in New Issue
Block a user