generated from Leo_Ding/web-template
Compare commits
3 Commits
232bcae504
...
66f7e74b8e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
66f7e74b8e | ||
|
|
acbb5f642b | ||
|
|
2375cddadb |
2
.env.dev
2
.env.dev
@ -13,7 +13,7 @@ VITE_ROUTER_HISTORY=hash
|
|||||||
|
|
||||||
# api
|
# api
|
||||||
VITE_API_BASIC=https://api.hailin-keji.com
|
VITE_API_BASIC=https://api.hailin-keji.com
|
||||||
# VITE_API_BASIC=http://10.10.1.6:8060
|
#VITE_API_BASIC=http://10.10.1.6:8060
|
||||||
VITE_API_HTTP=/api/v1/
|
VITE_API_HTTP=/api/v1/
|
||||||
# storage
|
# storage
|
||||||
VITE_STORAGE_NAMESPACE = gin-admin_local_
|
VITE_STORAGE_NAMESPACE = gin-admin_local_
|
||||||
|
|||||||
14
src/apis/modules/companies.js
Normal file
14
src/apis/modules/companies.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* 海邻大事记动态接口
|
||||||
|
*/
|
||||||
|
import request from '@/utils/request'
|
||||||
|
// 获取菜单列表
|
||||||
|
export const getCompanies = (params) => request.basic.get('/api/v1/companies ', params)
|
||||||
|
// 获取菜单条数据
|
||||||
|
export const getMenuCompanies = (id) => request.basic.get(`/api/v1/companies/${id}`)
|
||||||
|
// 添加菜单
|
||||||
|
export const createCompaniesMenu = (params) => request.basic.post('/api/v1/companies', params)
|
||||||
|
// 更新菜单
|
||||||
|
export const updateCompanies = (id, params) => request.basic.put(`/api/v1/companies/${id}`, params)
|
||||||
|
// 删除菜单
|
||||||
|
export const delCompanies = (id) => request.basic.delete(`/api/v1/companies/${id}`)
|
||||||
@ -32,12 +32,13 @@ export default {
|
|||||||
account: '个人页',
|
account: '个人页',
|
||||||
'account.trigger': '触发报错',
|
'account.trigger': '触发报错',
|
||||||
'account.logout': '退出登录',
|
'account.logout': '退出登录',
|
||||||
imgMgt:'图片管理',
|
imgMgt:'首页',
|
||||||
homeBanner:'首页轮播图',
|
homeBanner:'首页轮播图',
|
||||||
about:'关于海邻',
|
about:'关于海邻左侧背景图',
|
||||||
researchHonor:'科研成果',
|
researchHonor:'科研成果',
|
||||||
|
AboutY:'关于海邻',
|
||||||
corporateHonor:'企业荣誉',
|
corporateHonor:'企业荣誉',
|
||||||
talentCenter:'办公环境',
|
talentCenter:'人才中心',
|
||||||
teamStyle:'团队风采',
|
teamStyle:'团队风采',
|
||||||
Dynamic:'海邻动态',
|
Dynamic:'海邻动态',
|
||||||
companyNews:'公司动态',
|
companyNews:'公司动态',
|
||||||
@ -46,10 +47,21 @@ export default {
|
|||||||
recruitment:'招聘岗位',
|
recruitment:'招聘岗位',
|
||||||
product:'产品中心',
|
product:'产品中心',
|
||||||
team:'技术团队',
|
team:'技术团队',
|
||||||
importantEvents:'海邻大事记',
|
importantEvents:'发展历程',
|
||||||
websiteRelated:'网站相关',
|
websiteRelated:'联系我们',
|
||||||
friendlyLinks:'友情链接',
|
friendlyLinks:'友情链接',
|
||||||
websiteStatement:'网站声明',
|
websiteStatement:'网站声明',
|
||||||
contactUs:'联系我们',
|
contactUs:'联系我们',
|
||||||
productType:'产品分类'
|
productType:'产品分类',
|
||||||
|
productY:'产品中心',
|
||||||
|
productCentre:'产品中心',
|
||||||
|
productClassify:'产品分类',
|
||||||
|
technologyCenter:'技术中心',
|
||||||
|
environment:'办公环境',
|
||||||
|
other:'其他',
|
||||||
|
logo: '海邻logo',
|
||||||
|
officialWeChat:'官方微信',
|
||||||
|
Profile:'企业简介',
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
export default {
|
export default {
|
||||||
'pages.layouts.userLayout.title':
|
'pages.layouts.userLayout.title': '成为中国领先的新型饲用蛋白供应商',
|
||||||
'成为中国领先的新型饲用蛋白供应商',
|
|
||||||
'pages.login.accountLogin.tab': '账户密码登录',
|
'pages.login.accountLogin.tab': '账户密码登录',
|
||||||
'pages.login.failure': '登录失败,请重试!',
|
'pages.login.failure': '登录失败,请重试!',
|
||||||
'pages.login.success': '登录成功!',
|
'pages.login.success': '登录成功!',
|
||||||
|
|||||||
51
src/router/routes/AboutY.js
Normal file
51
src/router/routes/AboutY.js
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
import { DeploymentUnitOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: 'AboutY',
|
||||||
|
name: 'AboutY',
|
||||||
|
component: 'RouteViewLayout',
|
||||||
|
meta: {
|
||||||
|
icon: DeploymentUnitOutlined,
|
||||||
|
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: 'corporateHonor',
|
||||||
|
name: 'corporateHonor',
|
||||||
|
component: 'AboutY/corporateHonor/index.vue',
|
||||||
|
meta: {
|
||||||
|
title: '企业荣誉',
|
||||||
|
isMenu: true,
|
||||||
|
keepAlive: true,
|
||||||
|
permission: '*',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
@ -46,39 +46,39 @@ export default [
|
|||||||
permission: '*',
|
permission: '*',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
path: 'corporateHonor',
|
// path: 'corporateHonor',
|
||||||
name: 'corporateHonor',
|
// name: 'corporateHonor',
|
||||||
component: 'imgMgt/corporateHonor/index.vue',
|
// component: 'imgMgt/corporateHonor/index.vue',
|
||||||
meta: {
|
// meta: {
|
||||||
title: '企业荣誉',
|
// title: '企业荣誉',
|
||||||
isMenu: true,
|
// isMenu: true,
|
||||||
keepAlive: true,
|
// keepAlive: true,
|
||||||
permission: '*',
|
// permission: '*',
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
path: 'talentCenter',
|
// path: 'talentCenter',
|
||||||
name: 'talentCenter',
|
// name: 'talentCenter',
|
||||||
component: 'imgMgt/talentCenter/index.vue',
|
// component: 'imgMgt/talentCenter/index.vue',
|
||||||
meta: {
|
// meta: {
|
||||||
title: '人才中心',
|
// title: '人才中心',
|
||||||
isMenu: true,
|
// isMenu: true,
|
||||||
keepAlive: true,
|
// keepAlive: true,
|
||||||
permission: '*',
|
// permission: '*',
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
path: 'teamStyle',
|
// path: 'teamStyle',
|
||||||
name: 'teamStyle',
|
// name: 'teamStyle',
|
||||||
component: 'imgMgt/teamStyle/index.vue',
|
// component: 'imgMgt/teamStyle/index.vue',
|
||||||
meta: {
|
// meta: {
|
||||||
title: '团队风采',
|
// title: '团队风采',
|
||||||
isMenu: true,
|
// isMenu: true,
|
||||||
keepAlive: true,
|
// keepAlive: true,
|
||||||
permission: '*',
|
// 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 other from './other'
|
||||||
import imgMgt from './imgMgt'
|
import imgMgt from './imgMgt'
|
||||||
import dynamic from './dynamic'
|
import dynamic from './dynamic'
|
||||||
import recruitment from './recruitment'
|
// import recruitment from './recruitment'
|
||||||
import product from './product'
|
import product from './product'
|
||||||
import team from './team'
|
import technologyCenter from './technologyCenter'
|
||||||
import importantEvents from './importantEvents'
|
|
||||||
import website from './websiteRelated'
|
import website from './websiteRelated'
|
||||||
|
import AboutY from './AboutY'
|
||||||
|
import talentCenter from './talentCenter'
|
||||||
export default [
|
export default [
|
||||||
...home,
|
...home,
|
||||||
...form,
|
...form,
|
||||||
@ -31,9 +31,10 @@ export default [
|
|||||||
...other,
|
...other,
|
||||||
...imgMgt,
|
...imgMgt,
|
||||||
...dynamic,
|
...dynamic,
|
||||||
...recruitment,
|
//...recruitment,
|
||||||
...product,
|
...product,
|
||||||
...team,
|
...technologyCenter,
|
||||||
...importantEvents,
|
|
||||||
...website,
|
...website,
|
||||||
|
...AboutY,
|
||||||
|
...talentCenter,
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,3 +1,69 @@
|
|||||||
|
// import { EllipsisOutlined } from '@ant-design/icons-vue'
|
||||||
|
//
|
||||||
|
// export default [
|
||||||
|
// {
|
||||||
|
// path: 'other',
|
||||||
|
// name: 'other',
|
||||||
|
// component: 'RouteViewLayout',
|
||||||
|
// meta: {
|
||||||
|
// icon: EllipsisOutlined,
|
||||||
|
// title: '其他',
|
||||||
|
// isMenu: true,
|
||||||
|
// keepAlive: true,
|
||||||
|
// permission: '*',
|
||||||
|
// },
|
||||||
|
// children: [
|
||||||
|
// {
|
||||||
|
// path: 'logo',
|
||||||
|
// name: 'logo',
|
||||||
|
// component: 'other/logo/index.vue',
|
||||||
|
// meta: {
|
||||||
|
// layout: 'CustomLayout',
|
||||||
|
// title: '海邻logo',
|
||||||
|
// isMenu: true,
|
||||||
|
// target: '_blank',
|
||||||
|
// keepAlive: true,
|
||||||
|
// permission: '*',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// path: 'officialWeChat',
|
||||||
|
// name: 'officialWeChat',
|
||||||
|
// component: 'other/officialWeChat/index.vue',
|
||||||
|
// meta: {
|
||||||
|
// layout: 'CustomLayout',
|
||||||
|
// title: '官方微信',
|
||||||
|
// isMenu: true,
|
||||||
|
// target: '_blank',
|
||||||
|
// keepAlive: true,
|
||||||
|
// permission: '*',
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
// // {
|
||||||
|
// // path: 'multi-tab',
|
||||||
|
// // name: 'otherMultiTab',
|
||||||
|
// // component: 'other/multi-tab/index.vue',
|
||||||
|
// // meta: {
|
||||||
|
// // title: '多标签操作',
|
||||||
|
// // isMenu: true,
|
||||||
|
// // keepAlive: true,
|
||||||
|
// // permission: '*',
|
||||||
|
// // },
|
||||||
|
// // },
|
||||||
|
// // {
|
||||||
|
// // path: 'badge',
|
||||||
|
// // name: 'otherBadge',
|
||||||
|
// // component: 'other/badge/index.vue',
|
||||||
|
// // meta: {
|
||||||
|
// // title: '菜单徽标',
|
||||||
|
// // isMenu: true,
|
||||||
|
// // keepAlive: true,
|
||||||
|
// // permission: '*',
|
||||||
|
// // },
|
||||||
|
// // },
|
||||||
|
// ],
|
||||||
|
// },
|
||||||
|
// ]
|
||||||
import { EllipsisOutlined } from '@ant-design/icons-vue'
|
import { EllipsisOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
@ -14,35 +80,22 @@ export default [
|
|||||||
},
|
},
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: 'custom-layout',
|
path: 'logo',
|
||||||
name: 'otherCustomLayout',
|
name: 'logo',
|
||||||
component: '/list/basic/index.vue',
|
component: 'other/logo/index.vue',
|
||||||
meta: {
|
meta: {
|
||||||
layout: 'CustomLayout',
|
title: 'logo',
|
||||||
title: '自定义框架',
|
|
||||||
isMenu: true,
|
|
||||||
target: '_blank',
|
|
||||||
keepAlive: true,
|
|
||||||
permission: '*',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
path: 'multi-tab',
|
|
||||||
name: 'otherMultiTab',
|
|
||||||
component: '/other/multi-tab/index.vue',
|
|
||||||
meta: {
|
|
||||||
title: '多标签操作',
|
|
||||||
isMenu: true,
|
isMenu: true,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
permission: '*',
|
permission: '*',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'badge',
|
path: 'officialWeChat',
|
||||||
name: 'otherBadge',
|
name: 'officialWeChat',
|
||||||
component: 'other/badge/index.vue',
|
component: 'other/officialWeChat/index.vue',
|
||||||
meta: {
|
meta: {
|
||||||
title: '菜单徽标',
|
title: '官方微信',
|
||||||
isMenu: true,
|
isMenu: true,
|
||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
permission: '*',
|
permission: '*',
|
||||||
|
|||||||
@ -1,10 +1,38 @@
|
|||||||
|
// 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 { ShoppingOutlined } from '@ant-design/icons-vue'
|
import { ShoppingOutlined } from '@ant-design/icons-vue'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
{
|
{
|
||||||
path: 'product',
|
path: 'productY',
|
||||||
name: 'product',
|
name: 'productY',
|
||||||
component: 'product/index.vue',
|
component: 'RouteViewLayout',
|
||||||
meta: {
|
meta: {
|
||||||
icon: ShoppingOutlined,
|
icon: ShoppingOutlined,
|
||||||
title: '产品中心',
|
title: '产品中心',
|
||||||
@ -12,17 +40,29 @@ export default [
|
|||||||
keepAlive: true,
|
keepAlive: true,
|
||||||
permission: '*',
|
permission: '*',
|
||||||
},
|
},
|
||||||
},
|
children: [
|
||||||
{
|
{
|
||||||
path: 'productType',
|
path: 'productClassify',
|
||||||
name: 'productType',
|
name: 'productClassify',
|
||||||
component: 'productType/index.vue',
|
component: 'productY/productClassify/index.vue',
|
||||||
meta: {
|
meta: {
|
||||||
icon: ShoppingOutlined,
|
title: '产品分类',
|
||||||
title: '产品分类',
|
isMenu: true,
|
||||||
isMenu: true,
|
keepAlive: true,
|
||||||
keepAlive: true,
|
permission: '*',
|
||||||
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: '*',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
]
|
||||||
213
src/views/AboutY/Profile/index.vue
Normal file
213
src/views/AboutY/Profile/index.vue
Normal file
@ -0,0 +1,213 @@
|
|||||||
|
<template>
|
||||||
|
<x-search-bar class="mb-8-2">
|
||||||
|
<template #default="{ gutter, colSpan }">
|
||||||
|
<a-form-item :label="'零容忍'" name="reportContent">
|
||||||
|
<a-textarea :placeholder="'请输入零容忍内容'" v-model:value="reportContent"></a-textarea>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'零容忍图片'" name="reportImage">
|
||||||
|
<!-- <x-upload-image v-model="reportImage" @imgChange="imgChange" />-->
|
||||||
|
<gx-upload v-model="reportImage" :fileNumber="1" />
|
||||||
|
<p class="hint">750*500px,图片大小不超过150kb</p>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'举报邮箱'" name="email">
|
||||||
|
<a-input :placeholder="'请输入举报邮箱'" v-model:value="email"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'经度'" name="lat">
|
||||||
|
<a-input-number :placeholder="'请输入经度'" v-model:value="lat"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'纬度'" name="lon">
|
||||||
|
<a-input-number :placeholder="'请输入经度'" v-model:value="lon"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'地址'" name="address">
|
||||||
|
<a-input :placeholder="'请输入地址'" v-model:value="address"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'电话'" name="phone">
|
||||||
|
<a-input :placeholder="'请输入电话'" v-model:value="phone"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item :label="'编码'" name="reportNum">
|
||||||
|
<a-input :placeholder="'请输入编码'" v-model:value="reportNum"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
<template v-if="Array.isArray(socialMedia)">
|
||||||
|
<a-form-item
|
||||||
|
v-for="(itemImg, index) in socialMedia"
|
||||||
|
:key="index"
|
||||||
|
:label="itemImg.name || `社交媒体${index + 1}`">
|
||||||
|
<a-input
|
||||||
|
class="inputPhone"
|
||||||
|
v-model:value="itemImg.name"
|
||||||
|
placeholder="请输入图片名称"
|
||||||
|
/>
|
||||||
|
<gx-upload
|
||||||
|
v-model="itemImg.image"
|
||||||
|
:fileNumber="1"
|
||||||
|
/>
|
||||||
|
<p class="hint">106*106px,图片大小不超过50kb</p>
|
||||||
|
<a-input
|
||||||
|
class="inputPhone"
|
||||||
|
v-model:value="itemImg.link"
|
||||||
|
placeholder="请输入跳转链接"
|
||||||
|
/>
|
||||||
|
<a-button
|
||||||
|
danger
|
||||||
|
@click="removeSocialMedia(index)"
|
||||||
|
size="small"
|
||||||
|
style="margin-bottom: 20px">删除
|
||||||
|
</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item>
|
||||||
|
<a-button
|
||||||
|
type="dashed"
|
||||||
|
block
|
||||||
|
@click="addSocialMedia">新增社交媒体
|
||||||
|
</a-button>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<x-editor :modelValue="affirm" @update:modelValue="affirm = $event" placeholder="请输入声明内容"></x-editor>
|
||||||
|
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
||||||
|
</template>
|
||||||
|
</x-search-bar>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import apis from '@/apis' // 假设这里包含 saveAffirm 接口
|
||||||
|
import { usePagination } from '@/hooks'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { spliceUrl } from '@/utils/util'
|
||||||
|
import { getWebData,updateWebData} from '@/apis/modules/webSite'
|
||||||
|
import XSearchBar from '@/components/SearchBar/SearchBar.vue'
|
||||||
|
import GxUpload from '@/components/GxUpload/index.vue' // 获取声明接口
|
||||||
|
import { config } from '@/config'
|
||||||
|
import { getCompanies } from '@/apis/modules/companies'
|
||||||
|
defineOptions({
|
||||||
|
name: 'contactUs',
|
||||||
|
})
|
||||||
|
const { t } = useI18n()
|
||||||
|
const { showLoading, hideLoading } = usePagination()
|
||||||
|
const affirm = ref(null)
|
||||||
|
const id = ref(null)
|
||||||
|
const reportContent = ref(null)
|
||||||
|
const reportImage = ref(null)
|
||||||
|
const email = ref(null)
|
||||||
|
const lat = ref(null)
|
||||||
|
const lon = ref(null)
|
||||||
|
const address = ref(null)
|
||||||
|
const phone = ref(null)
|
||||||
|
const reportNum = ref(null)
|
||||||
|
const socialMedia = ref([{ name: '', image: '', link: '' }])
|
||||||
|
const imgChange = (index, value) => {
|
||||||
|
socialMedia.value[index].image = value
|
||||||
|
reportImage.value = value
|
||||||
|
}
|
||||||
|
// 页面加载时获取声明内容
|
||||||
|
getPageList()
|
||||||
|
/**
|
||||||
|
* 获取声明内容
|
||||||
|
*/
|
||||||
|
async function getPageList() {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
const res = await getCompanies() // 假设返回格式为 { data: { affirm: '内容' } }
|
||||||
|
if (res?.data) {
|
||||||
|
id.value = res.data.id
|
||||||
|
affirm.value = res.data.affirm
|
||||||
|
reportContent.value = res.data.reportContent
|
||||||
|
reportImage.value = [config('http.apiBasic')+res.data.reportImage]
|
||||||
|
email.value = res.data.email
|
||||||
|
lat.value = res.data.lat
|
||||||
|
lon.value = res.data.lon
|
||||||
|
address.value = res.data.address
|
||||||
|
phone.value = res.data.phone
|
||||||
|
reportNum.value = res.data.reportNum
|
||||||
|
socialMedia.value = Array.isArray(res.data.socialMedia) ? res.data.socialMedia.map(item=>({link:item.link,name:item.name,image:[config('http.apiBasic')+item.image]})) : []
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
message.error('获取声明内容失败')
|
||||||
|
} finally {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 提交声明内容
|
||||||
|
*/
|
||||||
|
async function handleSearch() {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
// 转换 socialMedia.image 为字符串
|
||||||
|
// const formattedSocialMedia = Array.isArray(socialMedia.value)
|
||||||
|
// ? socialMedia.value.map(item => ({
|
||||||
|
// ...item,
|
||||||
|
// image: Array.isArray(item.image) ? item.image[0] : item.image
|
||||||
|
// }))
|
||||||
|
// : []
|
||||||
|
const formattedSocialMedia = Array.isArray(socialMedia?.value)
|
||||||
|
? socialMedia.value.map(item => {
|
||||||
|
const imageRaw = Array.isArray(item?.image)
|
||||||
|
? item.image[0]
|
||||||
|
: item?.image;
|
||||||
|
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
image: spliceUrl(imageRaw)
|
||||||
|
};
|
||||||
|
})
|
||||||
|
: [];
|
||||||
|
|
||||||
|
const reportImageRaw = Array.isArray(reportImage?.value)
|
||||||
|
? reportImage.value[0]
|
||||||
|
: reportImage?.value;
|
||||||
|
const reportImageFormatted = {
|
||||||
|
reportImage: spliceUrl(reportImageRaw)};
|
||||||
|
|
||||||
|
await apis.webSite.updateWebData(id.value, {
|
||||||
|
affirm: affirm.value,
|
||||||
|
reportContent: reportContent.value,
|
||||||
|
reportImage: reportImageFormatted.reportImage,
|
||||||
|
//reportImage:Array.isArray(reportImage.value) ? reportImage.value[0] : reportImage.value,
|
||||||
|
email: email.value,
|
||||||
|
lat: lat.value,
|
||||||
|
lon: lon.value,
|
||||||
|
address: address.value,
|
||||||
|
phone: phone.value,
|
||||||
|
reportNum: reportNum.value,
|
||||||
|
socialMedia: formattedSocialMedia,
|
||||||
|
})
|
||||||
|
// await apis.webSite.updateWebData(id.value, {
|
||||||
|
// affirm: affirm.value,
|
||||||
|
// reportContent: reportContent.value,
|
||||||
|
//
|
||||||
|
// reportImage: reportImage.value,
|
||||||
|
//
|
||||||
|
// email: email.value,
|
||||||
|
// lat: lat.value,
|
||||||
|
// lon: lon.value,
|
||||||
|
// address: address.value,
|
||||||
|
// phone: phone.value,
|
||||||
|
// reportNum: reportNum.value,
|
||||||
|
//
|
||||||
|
// socialMedia: socialMedia.value,
|
||||||
|
// })
|
||||||
|
message.success('保存成功')
|
||||||
|
} catch (e) {
|
||||||
|
message.error('保存失败,请重试')
|
||||||
|
} finally {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addSocialMedia() {
|
||||||
|
socialMedia.value.push({ name: '', image: '', link: '' })
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeSocialMedia(index) {
|
||||||
|
socialMedia.value.splice(index, 1)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
203
src/views/AboutY/corporateHonor/components/EditDialog.vue
Normal file
203
src/views/AboutY/corporateHonor/components/EditDialog.vue
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
<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" />
|
||||||
|
<p class="hint">406*270px,图片大小不要超过200kb</p>
|
||||||
|
</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>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</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>
|
||||||
@ -50,6 +50,7 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'图片'" name="imgUrl">
|
<a-form-item :label="'图片'" name="imgUrl">
|
||||||
<x-upload-image v-model="imgUrl" @imgChange="imgChange" />
|
<x-upload-image v-model="imgUrl" @imgChange="imgChange" />
|
||||||
|
<p class="hint">683*339px,图片大小不超过900kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -222,4 +223,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -36,6 +36,7 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'图片'" name="imgUrl">
|
<a-form-item :label="'图片'" name="imgUrl">
|
||||||
<x-upload-image v-model="imgUrl" @imgChange="imgChange" />
|
<x-upload-image v-model="imgUrl" @imgChange="imgChange" />
|
||||||
|
<p class="hint">240*155px,图片大小不超过100kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -208,4 +209,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -15,11 +15,11 @@
|
|||||||
<!-- <a-textarea :placeholder="'请输入内容'" v-model:value="formData.subheading"></a-textarea>-->
|
<!-- <a-textarea :placeholder="'请输入内容'" v-model:value="formData.subheading"></a-textarea>-->
|
||||||
<!-- </a-form-item>-->
|
<!-- </a-form-item>-->
|
||||||
<!-- </a-col>-->
|
<!-- </a-col>-->
|
||||||
<a-col :span="24">
|
<!-- <a-col :span="24">-->
|
||||||
<a-form-item :label="'链接'" name="link">
|
<!-- <a-form-item :label="'链接'" name="link">-->
|
||||||
<a-input v-model:value="formData.link" :placeholder="'请输入链接'" />
|
<!-- <a-input v-model:value="formData.link" :placeholder="'请输入链接'" />-->
|
||||||
</a-form-item>
|
<!-- </a-form-item>-->
|
||||||
</a-col>
|
<!-- </a-col>-->
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'日期'" name="pushAt">
|
<a-form-item :label="'日期'" name="pushAt">
|
||||||
<a-date-picker v-model:value="formData.pushAt" :format="'YYYY-MM-DD'" placeholder="选择日期" style="width: 100%;">
|
<a-date-picker v-model:value="formData.pushAt" :format="'YYYY-MM-DD'" placeholder="选择日期" style="width: 100%;">
|
||||||
@ -37,11 +37,13 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'大图片'" name="fullImg">
|
<a-form-item :label="'大图片'" name="fullImg">
|
||||||
<x-upload-image v-model="fullImg" @imgChange="(val) => imgChange(val, 'fullImg')" />
|
<x-upload-image v-model="fullImg" @imgChange="(val) => imgChange(val, 'fullImg')" />
|
||||||
|
<p class="hint">大图片尺寸:1400*350px,图片大小不超过900kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'小图片'" name="smallImg">
|
<a-form-item :label="'小图片'" name="smallImg">
|
||||||
<x-upload-image v-model="smallImg" @imgChange="(val) => imgChange(val, 'smallImg')" />
|
<x-upload-image v-model="smallImg" @imgChange="(val) => imgChange(val, 'smallImg')" />
|
||||||
|
<p class="hint">小图片尺寸:256*146px,图片大小不超过900kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
@ -103,7 +105,7 @@ const videoUrl = ref([''])
|
|||||||
formRules.value = {
|
formRules.value = {
|
||||||
title: { required: true, message: '请输入标题' },
|
title: { required: true, message: '请输入标题' },
|
||||||
subheading: { required: false, message: '请输入内容' },
|
subheading: { required: false, message: '请输入内容' },
|
||||||
link: { required: false, message: '请输入链接' },
|
// link: { required: false, message: '请输入链接' },
|
||||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||||
pushAt: [{ required: true, message: '请选择发布日期', trigger: 'change' }],
|
pushAt: [{ required: true, message: '请选择发布日期', trigger: 'change' }],
|
||||||
fullImg: [{ required: false, message: '请上传大图片', trigger: 'change' }],
|
fullImg: [{ required: false, message: '请上传大图片', trigger: 'change' }],
|
||||||
@ -249,4 +251,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -67,12 +67,12 @@
|
|||||||
<!-- <span>{{ record.subheading }}</span>-->
|
<!-- <span>{{ record.subheading }}</span>-->
|
||||||
<!-- </a-tooltip>-->
|
<!-- </a-tooltip>-->
|
||||||
<!-- </template>-->
|
<!-- </template>-->
|
||||||
<template v-if="column.dataIndex === 'link'">
|
<!-- <template v-if="column.dataIndex === 'link'">-->
|
||||||
<a-tooltip :title="record.link">
|
<!-- <a-tooltip :title="record.link">-->
|
||||||
<a :href="record.link" target="_blank" style="text-decoration: underline;">{{
|
<!-- <a :href="record.link" target="_blank" style="text-decoration: underline;">{{-->
|
||||||
record.link }}</a>
|
<!-- record.link }}</a>-->
|
||||||
</a-tooltip>
|
<!-- </a-tooltip>-->
|
||||||
</template>
|
<!-- </template>-->
|
||||||
<template v-if="'status' === column.dataIndex">
|
<template v-if="'status' === column.dataIndex">
|
||||||
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
|
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
|
||||||
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
|
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
|
||||||
@ -149,8 +149,8 @@ const columns = [
|
|||||||
// { title: '简介', dataIndex: 'subheading', key: 'subheading' },
|
// { title: '简介', dataIndex: 'subheading', key: 'subheading' },
|
||||||
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
{ title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||||
{ title: '发布日期', dataIndex: 'pushAt', width: 120, align: 'center' },
|
{ title: '发布日期', dataIndex: 'pushAt', width: 120, align: 'center' },
|
||||||
{ title: '链接', dataIndex: 'link', align: 'center' },
|
//{ title: '链接', dataIndex: 'link', align: 'center' },
|
||||||
// { title: '月份+事件', dataIndex: 'month', key: 'month' },
|
//{ title: '月份+事件', dataIndex: 'month', key: 'month' },
|
||||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'图片'" name="img">
|
<a-form-item :label="'图片'" name="img">
|
||||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||||
|
<p class="hint">713*620px,图片大小不要超过300kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -195,4 +196,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint{
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'图片'" name="img">
|
<a-form-item :label="'图片'" name="img">
|
||||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||||
|
<p class="hint">1920*831px, 图片大小不要超过700kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -67,6 +68,7 @@ const handleChange = (value) => {
|
|||||||
const imgChange = (value) => {
|
const imgChange = (value) => {
|
||||||
formData.value.img = value
|
formData.value.img = value
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新建
|
* 新建
|
||||||
*/
|
*/
|
||||||
@ -194,4 +196,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'图片'" name="img">
|
<a-form-item :label="'图片'" name="img">
|
||||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||||
|
<p class="hint">314*432px,图片大小不要超过300kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -194,4 +195,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint{
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -1,37 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-card title="基础示例">
|
|
||||||
<a-space>
|
|
||||||
<a-input v-model:value="form.name"></a-input>
|
|
||||||
<a-input-number
|
|
||||||
v-model:value="form.count"
|
|
||||||
:min="0"></a-input-number>
|
|
||||||
<a-button @click="handleSet">设置</a-button>
|
|
||||||
<a-button @click="handleClear">清除</a-button>
|
|
||||||
</a-space>
|
|
||||||
</a-card>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import { useMenu } from '@/hooks'
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
name: 'otherBadge',
|
|
||||||
})
|
|
||||||
|
|
||||||
const form = ref({
|
|
||||||
name: 'home',
|
|
||||||
count: 10,
|
|
||||||
})
|
|
||||||
const { setBadge } = useMenu()
|
|
||||||
|
|
||||||
function handleSet() {
|
|
||||||
setBadge(form.value?.name, form.value?.count)
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClear() {
|
|
||||||
setBadge(form.value?.name, 0)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
|
||||||
169
src/views/other/logo/components/Department.vue
Normal file
169
src/views/other/logo/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>
|
||||||
131
src/views/other/logo/components/EditDepartmentDialog.vue
Normal file
131
src/views/other/logo/components/EditDepartmentDialog.vue
Normal file
@ -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>
|
||||||
208
src/views/other/logo/components/EditDialog.vue
Normal file
208
src/views/other/logo/components/EditDialog.vue
Normal file
@ -0,0 +1,208 @@
|
|||||||
|
<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" />
|
||||||
|
<p class="hint" v-if="formData.sequence == 1 ">400*70px,图片大小不超过150kb</p>
|
||||||
|
<p class="hint" v-if="formData.sequence == 0 ">300*50px,图片大小不超过150kb</p>
|
||||||
|
</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: 1 ,
|
||||||
|
// 120对应banner
|
||||||
|
}
|
||||||
|
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>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
:deep(.ant-table-cell) {
|
||||||
|
background-color: #ccc;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
202
src/views/other/logo/index.vue
Normal file
202
src/views/other/logo/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: 'logo',
|
||||||
|
})
|
||||||
|
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: 1,//logo
|
||||||
|
...searchFormData.value,
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
//筛选type的值80对应about
|
||||||
|
listData.value = data
|
||||||
|
paginationState.total = total
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
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>
|
||||||
@ -1,98 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<a-card title="打开">
|
|
||||||
<a-space>
|
|
||||||
<a-button @click="handleOpen">打开欢迎页</a-button>
|
|
||||||
</a-space>
|
|
||||||
</a-card>
|
|
||||||
<a-card
|
|
||||||
class="mt-8-2"
|
|
||||||
title="刷新">
|
|
||||||
<a-space>
|
|
||||||
<a-button @click="handleReload">刷新当前</a-button>
|
|
||||||
<span>{{ date }}</span>
|
|
||||||
</a-space>
|
|
||||||
</a-card>
|
|
||||||
<a-card
|
|
||||||
class="mt-8-2"
|
|
||||||
title="关闭">
|
|
||||||
<a-space>
|
|
||||||
<a-button @click="handleClose">关闭当前</a-button>
|
|
||||||
<a-button @click="handleCloseOther">关闭其他</a-button>
|
|
||||||
</a-space>
|
|
||||||
</a-card>
|
|
||||||
<a-card
|
|
||||||
class="mt-8-2"
|
|
||||||
title="设置">
|
|
||||||
<a-space>
|
|
||||||
<a-input v-model:value="title"></a-input>
|
|
||||||
<a-button @click="handleSetTitle">设置标题</a-button>
|
|
||||||
<a-button @click="handleRevertTitle">还原</a-button>
|
|
||||||
</a-space>
|
|
||||||
</a-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { onMounted, ref } from 'vue'
|
|
||||||
import { useRouter } from 'vue-router'
|
|
||||||
import { useMultiTab } from '@/hooks'
|
|
||||||
|
|
||||||
defineOptions({
|
|
||||||
name: 'otherMultiTab',
|
|
||||||
})
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const { reload, close, closeOther, setTitle } = useMultiTab()
|
|
||||||
const date = ref('')
|
|
||||||
const title = ref('自定义名称')
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
date.value = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 打开欢迎页
|
|
||||||
*/
|
|
||||||
function handleOpen() {
|
|
||||||
router.push({ name: 'home' })
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 刷新当前
|
|
||||||
*/
|
|
||||||
function handleReload() {
|
|
||||||
reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关闭
|
|
||||||
*/
|
|
||||||
function handleClose() {
|
|
||||||
close()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关闭其他
|
|
||||||
*/
|
|
||||||
function handleCloseOther() {
|
|
||||||
closeOther()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置标题
|
|
||||||
*/
|
|
||||||
function handleSetTitle() {
|
|
||||||
setTitle(title.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 还原标题
|
|
||||||
*/
|
|
||||||
function handleRevertTitle() {
|
|
||||||
setTitle(router.currentRoute.value.meta?.title)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
|
||||||
169
src/views/other/officialWeChat/components/Department.vue
Normal file
169
src/views/other/officialWeChat/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>
|
||||||
204
src/views/other/officialWeChat/components/EditDialog.vue
Normal file
204
src/views/other/officialWeChat/components/EditDialog.vue
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
<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" />
|
||||||
|
<p class="hint">80*80px,图片大小不超过50kb</p>
|
||||||
|
</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: 1000 ,
|
||||||
|
// 120对应banner
|
||||||
|
}
|
||||||
|
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>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
202
src/views/other/officialWeChat/index.vue
Normal file
202
src/views/other/officialWeChat/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: 'officialWeChat',
|
||||||
|
})
|
||||||
|
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: 1000,//官方微信
|
||||||
|
...searchFormData.value,
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
//筛选type的值80对应about
|
||||||
|
listData.value = data
|
||||||
|
paginationState.total = total
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
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>
|
||||||
437
src/views/productY/productCentre/components/EditDialog.vue
Normal file
437
src/views/productY/productCentre/components/EditDialog.vue
Normal file
@ -0,0 +1,437 @@
|
|||||||
|
<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" />
|
||||||
|
<p class="hint">包装图片尺寸:599*450px,感官图片尺寸:150*151px,图片大小不超过700kb</p>
|
||||||
|
</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>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</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>
|
||||||
203
src/views/talentCenter/environment/components/EditDialog.vue
Normal file
203
src/views/talentCenter/environment/components/EditDialog.vue
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
<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" />
|
||||||
|
<p class="hint">310*206px,图片大小不超过100kb</p>
|
||||||
|
</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>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</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 { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'homeBanner',
|
name: 'recruitment',
|
||||||
})
|
})
|
||||||
const { t } = useI18n() // 解构出t方法
|
const { t } = useI18n() // 解构出t方法
|
||||||
const columns = [
|
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>
|
||||||
203
src/views/talentCenter/teamStyle/components/EditDialog.vue
Normal file
203
src/views/talentCenter/teamStyle/components/EditDialog.vue
Normal file
@ -0,0 +1,203 @@
|
|||||||
|
<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" />
|
||||||
|
<p class="hint">380*285px,图片大小不超过150kb</p>
|
||||||
|
</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>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</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>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<!-- </a-col>-->
|
<!-- </a-col>-->
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'研究领域'" name="area">
|
<a-form-item :label="'研究领域'" name="area">
|
||||||
<a-input :placeholder="'请输入研究领域内容'" v-model:value="formData.area"></a-input>
|
<a-textarea :placeholder="'请输入研究领域内容'" v-model:value="formData.area"></a-textarea>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
@ -47,6 +47,7 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'图片'" name="img">
|
<a-form-item :label="'图片'" name="img">
|
||||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||||
|
<p class="hint">300*400px,图片大小不超过100kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -215,4 +216,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -50,6 +50,7 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'图片'" name="reportImage">
|
<a-form-item :label="'图片'" name="reportImage">
|
||||||
<x-upload-image v-model="reportImage" @imgChange="imgChange" />
|
<x-upload-image v-model="reportImage" @imgChange="imgChange" />
|
||||||
|
<p class="hint">750*500px,图片大小不超过150kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -222,4 +223,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@ -7,6 +7,7 @@
|
|||||||
<a-form-item :label="'零容忍图片'" name="reportImage">
|
<a-form-item :label="'零容忍图片'" name="reportImage">
|
||||||
<!-- <x-upload-image v-model="reportImage" @imgChange="imgChange" />-->
|
<!-- <x-upload-image v-model="reportImage" @imgChange="imgChange" />-->
|
||||||
<gx-upload v-model="reportImage" :fileNumber="1" />
|
<gx-upload v-model="reportImage" :fileNumber="1" />
|
||||||
|
<p class="hint">750*500px,图片大小不超过150kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="'举报邮箱'" name="email">
|
<a-form-item :label="'举报邮箱'" name="email">
|
||||||
<a-input :placeholder="'请输入举报邮箱'" v-model:value="email"></a-input>
|
<a-input :placeholder="'请输入举报邮箱'" v-model:value="email"></a-input>
|
||||||
@ -40,6 +41,7 @@
|
|||||||
v-model="itemImg.image"
|
v-model="itemImg.image"
|
||||||
:fileNumber="1"
|
:fileNumber="1"
|
||||||
/>
|
/>
|
||||||
|
<p class="hint">106*106px,图片大小不超过50kb</p>
|
||||||
<a-input
|
<a-input
|
||||||
class="inputPhone"
|
class="inputPhone"
|
||||||
v-model:value="itemImg.link"
|
v-model:value="itemImg.link"
|
||||||
@ -203,4 +205,8 @@ function removeSocialMedia(index) {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'图片'" name="img">
|
<a-form-item :label="'图片'" name="img">
|
||||||
<x-upload-image v-model="img" @imgChange="imgChange" />
|
<x-upload-image v-model="img" @imgChange="imgChange" />
|
||||||
|
<p class="hint">106*106px,图片大小不超过150kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
@ -199,4 +200,9 @@ defineExpose({
|
|||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
<style lang="less" scoped>
|
||||||
|
.hint {
|
||||||
|
color: red;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user