Commit dced7328 by 胡悦

提交新闻动态

1 parent c711b63a
......@@ -11,6 +11,8 @@
},
"dependencies": {
"@arco-plugins/vite-vue": "^1.4.5",
"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.12",
"axios": "^0.27.2",
"dayjs": "^1.11.12",
"echarts": "^5.4.0",
......
......@@ -3,14 +3,37 @@
* @Author: huyue
* @Date: 2024-07-23 14:30:40
* @LastEditors: huyue
* @LastEditTime: 2024-07-24 20:38:54
* @LastEditTime: 2024-10-15 11:33:50
-->
<script lang="ts" setup>
import NavBar from '@/components/NavBar/index.vue';
import Menu from '@/components/Menu/index.vue';
</script>
<template>
<router-view class />
<div class="layout">
<a-layout>
<a-layout-header><NavBar /></a-layout-header>
<a-layout>
<a-layout-sider>
<Menu />
</a-layout-sider>
<a-layout-content class="content">
<router-view></router-view>
</a-layout-content>
</a-layout>
</a-layout>
</div>
</template>
<script lang="ts" setup></script>
<style>
.flex-grow {
flex-grow: 1;
<style lang="scss" scoped>
.content {
box-sizing: border-box;
width: 100%;
height: calc(100vh - 48px);
background-color: #f7f8f9;
box-sizing: border-box;
padding: 16px 20px;
overflow-y: auto
}
</style>
</style>
\ No newline at end of file
// 有点丑陋 但是功能在
import { h, compile } from 'vue';
type Props = {
name: string;
};
const icon = (props: Props) => {
console.log(props.name)
return(props.name ? h(compile(`<${props.name}/>`)) : null, {size: 20})
}
export default icon;
\ No newline at end of file
<!--
* @Description: I
* @Author: huyue
* @Date: 2024-07-24 20:28:10
* @LastEditors: huyue
* @LastEditTime: 2024-10-17 16:09:34
-->
<script lang="ts" setup></script>
<script lang="ts" setup>
import { ref, onBeforeMount } from 'vue'
import staticRoutes from '@/router/routes'
import { useRouter, useRoute } from 'vue-router';
// import icon from './icon';
const router = useRouter();
const route = useRoute();
let defaultSelectedKeys = ref(['']);
const menuList = ref(staticRoutes.filter(item => item.isMenu));
onBeforeMount (() => {
console.log(route.path)
if (route.path == '/login') {
defaultSelectedKeys.value = ['/investorRelated']
} else {
defaultSelectedKeys.value = [route.path]
}
})
</script>
<template>
<div class="menu-box">
<a-menu
class="menu"
:style="{ width: '200px', height: '100%' }"
:default-open-keys="['0']"
:default-selected-keys="['0']"
:default-open-keys="defaultSelectedKeys"
:default-selected-keys="defaultSelectedKeys"
>
<a-menu-item key="0"><icon-user />投资者相关</a-menu-item>
<div v-for="(item, index) in menuList" :key="'menu-item-' + index">
<a-menu-item :key="item.path" @click="router.push(item.path)">
<!-- <icon :name="item.icon" /> -->
<template v-if="item.path === '/investorRelated'">
<icon-user />
</template>
<template v-if="item.path === '/news'">
<icon-public />
</template>
<span>{{ item.name }}</span>
</a-menu-item>
</div>
</a-menu>
</div>
</template>
......
......@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2022-10-10 10:54:14
* @LastEditors: huyue
* @LastEditTime: 2024-07-25 17:29:46
* @LastEditTime: 2024-10-15 18:22:56
*/
const staticRoutes = Object.freeze([
......@@ -17,25 +17,52 @@ const staticRoutes = Object.freeze([
component: () => import('views/login/index.vue'),
},
{
path: '/layout',
component: () => import('views/layout/index.vue'),
children: [
{
name: '投资者相关',
path: '/layout/investorRelated',
component: () => import('views/investorRelated/index.vue')
},
{
name: '新增公告',
path: '/layout/addInvnotice',
component: () => import('views/investorRelated/addInvnotice.vue'),
},
{
name: '新闻',
path: '/layout/news',
component: () => import('views/news/index.vue'),
}
]
id: '1',
name: '投资者相关',
path: '/investorRelated',
component: () => import('views/investorRelated/index.vue'),
isMenu: true,
icon: 'icon-user',
children: []
},
{
name: '新增公告',
path: '/investorRelated/addInvnotice',
component: () => import('views/investorRelated/addInvnotice.vue'),
},
{
id: '2',
name: '新闻动态',
path: '/news',
component: () => import('views/news/index.vue'),
isMenu: true,
icon: 'icon-public'
},
{
name: '新增动态',
path: '/news/addNews',
component: () => import('views/news/AddNews.vue'),
}
// {
// path: '/layout',
// component: () => import('views/layout/index.vue'),
// children: [
// {
// name: '投资者相关',
// path: '/layout/investorRelated',
// component: () => import('views/investorRelated/index.vue')
// },
// {
// name: '新增公告',
// path: '/layout/addInvnotice',
// component: () => import('views/investorRelated/addInvnotice.vue'),
// },
// {
// name: '新闻',
// path: '/layout/news',
// component: () => import('views/news/index.vue'),
// }
// ]
// },
])
export default staticRoutes
......@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2024-07-23 16:43:07
* @LastEditors: huyue
* @LastEditTime: 2024-08-02 11:12:39
* @LastEditTime: 2024-10-15 18:19:01
-->
<script lang="ts" setup>
import { h, reactive, inject } from "vue";
......@@ -120,7 +120,7 @@ const expandable = reactive({
/** 新增公告 */
const addInvnotice = () => {
router.push({
path: "/layout/addInvnotice",
path: "/investorRelated/addInvnotice",
});
}
/** 切换公告,参数类型 id */
......@@ -154,7 +154,7 @@ const publishOrDown = async(record: Partial<TableItem>) => {
const edit = (record: Partial<TableItem>) => {
router.push({
path: "/layout/addInvnotice",
path: "/investorRelated/addInvnotice",
query: {
id: record?.id
}
......@@ -165,7 +165,7 @@ const previewOA = (record: Partial<TableItem>) => {
data.imgVisible = true
data.imgUrl = record?.oaScreenshotUrl
} else {
Message.warning('暂无该数据')
Message.warning('未上传OA截图')
}
}
// 接口定义、调用
......
export interface TabItem {
gwInvnoticeTypeId: String;
description: String;
gwInvnoticeTypeId: string;
description: string;
}
export interface Page {
pageNum: Number;
pageSize: Number
pageNum: number;
pageSize: number
}
export interface BasicItem {
id: Number;
gwInvnoticeProductId: Number;
id: number;
gwInvnoticeProductId: number;
[property: string]: any;
}
export interface DataInfo {
tabList: TabItem[];
tableData: TableItem[]; // 表格数据
currentId?: Number | String;
total: Number;
currentId?: number | string;
total: number;
page: Page;
imgVisible: Boolean;
imgUrl: String;
imgUrl: string;
}
export interface TableItem {
id: Number;
gwInvnoticeTypeId: Number;
gwInvnoticeTypeName: String;
zhTitle: String;
modifiedAt?: String;
id: number;
gwInvnoticeTypeId: number;
gwInvnoticeTypeName: string;
zhTitle: string;
modifiedAt?: string;
invnoticeProductTranslationsList: Partial<BasicItem>[],
externalReleaseDate: String;
zhTag: String;
oaScreenshotUrl: String;
systemPublishStatus: Number;
externalReleaseDate: string;
zhTag: string;
oaScreenshotUrl: string;
systemPublishStatus: number;
}
......@@ -3,7 +3,7 @@
* @Author: huyue
* @Date: 2024-07-23 16:28:15
* @LastEditors: huyue
* @LastEditTime: 2024-07-30 18:25:37
* @LastEditTime: 2024-10-15 14:24:03
-->
<script lang="ts" setup>
import {ref, reactive, inject} from 'vue'
......@@ -55,7 +55,7 @@ const handleLogin = ({values, errors}: {
const { username, password } = userData;
if (values.username === username && values.password === password) {
router.push({
path: "/layout/investorRelated",
path: "/investorRelated",
});
} else {
loading.value = false;
......
<!--
* @Description:
* @Author: huyue
* @Date: 2024-10-15 18:05:34
* @LastEditors: huyue
* @LastEditTime: 2024-10-17 11:34:45
-->
<script lang="ts" setup>
import { useRouter, useRoute } from "vue-router";
import { reactive, onMounted, toRefs } from 'vue'
import { DataInfo } from "./addInterface";
import AddForm from "./components/AddForm.vue";
let route = useRoute()
let { query } = toRefs(route)
const router = useRouter();
const form = reactive<Partial<DataInfo>>({
name: ''
})
const back = () => {
router.go(-1)
}
/** 提交表单 */
const handleSubmit = () => {
console.log(form)
}
</script>
<template>
<a-breadcrumb>
<a-breadcrumb-item class="back" @click="back">新闻动态</a-breadcrumb-item>
<a-breadcrumb-item>{{query.id ? '编辑' : '新增'}}动态</a-breadcrumb-item>
</a-breadcrumb>
<div class="add-box">
<a-page-header :style="{ background: 'var(--color-bg-2)' }" :title="`${query.id ? '编辑' : '新增'}动态`" :show-back="false"></a-page-header>
<div class="form">
<AddForm></AddForm>
</div>
</div>
</template>
<style lang="scss" scoped>
.add-box {
margin-top: 12px;
background-color: #fff;
.form {
border-top: 1px solid #E6E8EB;
padding: 24px;
}
}
</style>
<style lang="scss">
.back {
&:hover {
cursor: pointer;
color: #195FFE;
}
}
</style>
\ No newline at end of file
export interface DataInfo {
publishType: number | string;
publishTime: string;
[key: string]: any;
}
\ No newline at end of file
function findAllImgSrcsFromHtml(htmlData) {
let imgReg = /<img.*?(?:>|\/>)/gi; //匹配图片中的img标签
let srcReg = /src=[\'\"]?([^\'\"]*)[\'\"]?/i; // 匹配图片中的src
let arr = htmlData.match(imgReg); //筛选出所有的img
if (!arr || (Array.isArray(arr) && !arr.length)) {
return false;
}
let srcArr = [];
for (let i = 0; i < arr.length; i++) {
let src = arr[i].match(srcReg);
// 获取图片地址
srcArr.push(src[1]);
}
return srcArr;
}
/**
* 从rtf内容中匹配返回图片数据的集合
* @param rtfData
* @return Array
*/
function extractImageDataFromRtf(rtfData) {
if (!rtfData) {
return [];
}
const regexPictureHeader = /{\\pict[\s\S]+?({\\\*\\blipuid\s?[\da-fA-F]+)[\s}]*/
const regexPicture = new RegExp('(?:(' + regexPictureHeader.source + '))([\\da-fA-F\\s]+)\\}', 'g');
const images = rtfData.match(regexPicture);
const result = [];
if (images) {
for (const image of images) {
let imageType = false;
if (image.includes('\\pngblip')) {
imageType = 'image/png';
} else if (image.includes('\\jpegblip')) {
imageType = 'image/jpeg';
}
if (imageType) {
result.push({
hex: image.replace(regexPictureHeader, '').replace(/[^\da-fA-F]/g, ''),
type: imageType
});
}
}
}
return result;
}
/**
* 将html内容中img标签的属性值替换
* @param htmlData html内容
* @param imageSrcs html中img的属性src的值的集合
* @param imagesHexSources rtf中图片数据的集合,与html内容中的img标签对应
* @param isBase64Data 是否是Base64的图片数据
* @return String
*/
function replaceImagesFileSourceWithInlineRepresentation(htmlData, imageSrcs, imagesHexSources, isBase64Data =
true) {
if (imageSrcs.length === imagesHexSources.length) {
for (let i = 0; i < imageSrcs.length; i++) {
const newSrc = isBase64Data ?
`data:${imagesHexSources[i].type};base64,${_convertHexToBase64(imagesHexSources[i].hex)}` :
imagesHexSources[i];
htmlData = htmlData.replace(imageSrcs[i], newSrc);
}
}
return htmlData;
}
/**
* 十六进制转base64
*/
function _convertHexToBase64(hexString) {
return btoa(hexString.match(/\w{2}/g).map(char => {
return String.fromCharCode(parseInt(char, 16));
}).join(''));
}
export {
findAllImgSrcsFromHtml,
extractImageDataFromRtf,
replaceImagesFileSourceWithInlineRepresentation,
_convertHexToBase64
}
\ No newline at end of file
......@@ -3,8 +3,157 @@
* @Author: huyue
* @Date: 2024-07-23 16:43:07
* @LastEditors: huyue
* @LastEditTime: 2024-07-24 17:23:08
* @LastEditTime: 2024-10-17 15:27:23
-->
<script lang="ts" setup>
import { ref } from 'vue'
import { req } from "../../utils/request";
import { Message } from "@arco-design/web-vue";
import { TableItem } from "./interface";
import { useRouter } from "vue-router";
const router = useRouter();
const data = ref({
page: {
pageNum: 1,
pageSize: 10
},
total: 0,
imgVisible: false,
imgUrl: ''
})
const tableData = ref([])
/** table列配置 */
const columns = [
{
title: '序号',
slotName: 'index',
width: '100',
},
{
title: "标题",
dataIndex: "title",
// width: '600',
// ellipsis: true,
// tooltip: true
},
{
title: "修改时间",
dataIndex: "updatedTime",
},
{
title: "发布时间",
dataIndex: "publishTime",
},
{
title: "操作",
slotName: 'operation',
}
];
/** 操作类 */
const publishOrDown = async(record: Partial<TableItem>) => {
const { id } = record
const res = await req("gw.api.news.information.upOrDown", {
id,
publishStatus: 2
})
if (res) Message.success('下架成功') // 没有发布时,若添加发布功能,需修改此处
getTableData()
}
/** 新增 */
const addNews = () => {
router.push({
path: "/news/addNews"
});
}
const edit = (item: Partial<TableItem>) => {
router.push({
path: "/news/addNews",
query: {
id: item?.id
}
});
}
const previewOA = (record: Partial<TableItem>) => {
if (record?.oaCover) {
data.value.imgVisible = true
data.value.imgUrl = record?.oaCover
} else {
Message.warning('未上传OA截图')
}
}
/** 分页切换 */
const changePage = (current: number) => {
data.value.page!.pageNum = current
getTableData()
}
const changeSize = (size: number) => {
data.value.page!.pageNum = 1
data.value.page!.pageSize = size
getTableData()
}
const getTableData = async () => {
let { page } = data.value
const res = await req("gw.api.news.information.page", {
...page
})
data.value.total = res.total
tableData.value = res.list
}
getTableData()
</script>
<template>
新闻
</template>
\ No newline at end of file
<div class="page-title">新闻动态</div>
<div class="page-content">
<div class="table-title">
<span>动态列表</span>
<a-button type="primary" @click="addNews">新增动态</a-button>
</div>
<a-table class="table" :columns="columns" :data="tableData" row-key="id" :pagination="false" :bordered="false">
<template #index="{ rowIndex }"> {{ data.page.pageSize * (data.page.pageNum - 1) + rowIndex + 1 }} </template>
<template #operation="{ record }">
<a-popconfirm :content="'是否确认下架'" @ok="publishOrDown(record)">
<!-- <a-button type="text" v-if="record.systemPublishStatus === 1 || record.systemPublishStatus === 2">发布</a-button> -->
<a-button type="text" v-if="record.publishStatus === 1">下架</a-button>
</a-popconfirm>
<a-button type="text" @click="edit(record)" v-if="record.publishStatus === 2 || record.publishStatus === 3">编辑</a-button>
<a-button type="text" @click="previewOA(record)">OA截图</a-button>
<a-image-preview
:src="data.imgUrl"
v-model:visible="data.imgVisible"
/>
</template>
</a-table>
<a-pagination class="pagination" :total="data.total" @change="changePage" @page-size-change="changeSize" show-total show-jumper show-page-size />
</div>
</template>
<style lang="scss" scoped>
.page-title {
font-weight: 500;
font-size: 20px;
color: #000814;
}
.page-content {
background-color: #fff;
padding: 10px 20px;
margin-top: 16px;
}
.pagination {
justify-content: flex-end;
padding: 16px 0;
}
.table-title {
display: flex;
align-items: center;
justify-content: space-between;
span {
font-size: 16px;
color: #000814;
}
}
.table {
margin-top: 10px;
}
</style>
\ No newline at end of file
export interface TableItem {
id: number;
title: string;
content: string;
updatedTime?: string;
publishTime: string;
publishStatus: number;
publishType: number;
oaCover: string;
}
\ No newline at end of file
......@@ -18,6 +18,6 @@
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
},
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue", "src/views/news/components/tool.ts", "src/views/news/components/tool.ts"],
"references": [{ "path": "./tsconfig.node.json" }]
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!