Browse Source

文章相关页面

zmq 1 year ago
parent
commit
e3fc3d2586

+ 1 - 1
.env.development

@@ -3,4 +3,4 @@ ENV = 'development'
 
 # 本地环境接口地址
 VITE_API_URL = 'http://localhost:8000'
-# VITE_API_URL = 'http://192.144.191.50:8000'
+# VITE_API_URL = 'http://dtadmin.zhongjie51.com'

+ 1 - 1
.env.production

@@ -9,4 +9,4 @@ VITE_PUBLIC_PATH = '/'
 
 # 线上环境接口地址
 # VITE_API_URL = 'https://admin.zhontai.net'
-VITE_API_URL = 'http://192.144.191.50:8000'
+VITE_API_URL = 'http://dtadmin.zhongjie51.com'

+ 129 - 0
src/api/admin/Article.ts

@@ -0,0 +1,129 @@
+/* eslint-disable */
+/* tslint:disable */
+/*
+ * ---------------------------------------------------------------
+ * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API        ##
+ * ##                                                           ##
+ * ## AUTHOR: acacode                                           ##
+ * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
+ * ---------------------------------------------------------------
+ */
+
+import { AxiosResponse } from 'axios'
+import {
+    ResultOutputAriticleGetOutput,
+    PageInputAriticleGetPageDto,
+    ResultOutputPageOutputAriticleListOutput,
+    AriticleAddInput,
+    AriticleUpdateInput,
+    ResultOutputInt64,    
+} from './data-contracts'
+import { ContentType, HttpClient, RequestParams } from './http-client'
+
+export class AriticelApi<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
+    /**
+     * No description
+     *
+     * @tags article
+     * @name Get
+     * @summary 查询模块
+     * @request GET:/api/admin/article/get
+     * @secure
+     */
+    get = (
+        query?: {
+            /** @format int64 */
+            id?: number
+        },
+        params: RequestParams = {}
+    ) =>
+        this.request<ResultOutputAriticleGetOutput, any>({
+            path: `/api/admin/article/get`,
+            method: 'GET',
+            query: query,
+            secure: true,
+            format: 'json',
+            ...params,
+        })
+    /**
+     * No description
+     *
+     * @tags article
+     * @name GetPage
+     * @summary 查询分页
+     * @request POST:/api/admin/article/get-page
+     * @secure
+     */
+    getPage = (data: PageInputAriticleGetPageDto, params: RequestParams = {}) =>
+        this.request<ResultOutputPageOutputAriticleListOutput, any>({
+            path: `/api/admin/article/get-page`,
+            method: 'POST',
+            body: data,
+            secure: true,
+            type: ContentType.Json,
+            format: 'json',
+            ...params,
+        })
+
+    /**
+     * No description
+     *
+     * @tags article
+     * @name Add
+     * @summary 新增
+     * @request POST:/api/admin/article/add
+     * @secure
+     */
+    add = (data: AriticleAddInput, params: RequestParams = {}) =>
+        this.request<ResultOutputInt64, any>({
+            path: `/api/admin/article/add`,
+            method: 'POST',
+            body: data,
+            secure: true,
+            type: ContentType.Json,
+            format: 'json',
+            ...params,
+        })
+    /**
+     * No description
+     *
+     * @tags article
+     * @name Update
+     * @summary 修改
+     * @request PUT:/api/admin/article/update
+     * @secure
+     */
+    update = (data: AriticleUpdateInput, params: RequestParams = {}) =>
+        this.request<AxiosResponse, any>({
+            path: `/api/admin/article/update`,
+            method: 'PUT',
+            body: data,
+            secure: true,
+            type: ContentType.Json,
+            ...params,
+        })   
+    /**
+   * No description
+   *
+   * @tags dict
+   * @name SoftDelete
+   * @summary 删除
+   * @request DELETE:/api/admin/article/soft-delete
+   * @secure
+   */
+    softDelete = (
+        query?: {
+            /** @format int64 */
+            id?: number
+        },
+        params: RequestParams = {}
+    ) =>
+        this.request<AxiosResponse, any>({
+            path: `/api/admin/article/soft-delete`,
+            method: 'DELETE',
+            query: query,
+            secure: true,
+            ...params,
+        })
+}
+

+ 74 - 0
src/api/admin/data-contracts.ts

@@ -5579,6 +5579,80 @@ export interface UpdateKuaKeStatusInput {
   status: number
 }
 //#endregion
+// #region 文章相关实体 start
 
+export interface ResultOutputAriticleGetOutput {
+  /** 是否成功标记 */
+  success?: boolean
+  /** 编码 */
+  code?: string | null
+  /** 消息 */
+  msg?: string | null
+  data?: AriticleGetOutput
+}
+
+export interface AriticleGetOutput {
+  title?: string | null
+  content?: string | null
+  contentOnly?: string | null
+  rank?: number | null
+  id?: number | null
+}
+export interface PageInputAriticleGetPageDto {
+  /**
+   * 当前页标
+   * @format int32
+   */
+  currentPage?: number
+  /**
+   * 每页大小
+   * @format int32
+   */
+  pageSize?: number
+  dynamicFilter?: DynamicFilterInfo
+  filter?: AriticleGetPageDto
+}
+export interface AriticleGetPageDto { 
+  keywrod?: string|null
+}
+export interface ResultOutputPageOutputAriticleListOutput {
+  /** 是否成功标记 */
+  success?: boolean
+  /** 编码 */
+  code?: string | null
+  /** 消息 */
+  msg?: string | null
+  data?: PageOutputAriticleListOutput
+}
+export interface PageOutputAriticleListOutput {
+  /**
+   * 数据总数
+   * @format int64
+   */
+  total?: number
+  /** 数据 */
+  list?: AriticleListOutput[] | null
+}
+export interface AriticleListOutput {  
+  id?: number  
+  title?: string | null
+  rank?: number | null
+  createdTime?: string | null
+}
+export interface AriticleAddInput {
+  id?: number
+  title?: string | null
+  content?: string | null
+  contentOnly?: string | null
+  rank?: number | null  
+}
+export interface AriticleUpdateInput {
+  id?: number
+  title?: string | null
+  content?: string | null
+  contentOnly?: string | null
+  rank?: number | null
+}
+//#endregion 文章相关实体 end
 
 

+ 4 - 1
src/types/mitt.d.ts

@@ -30,6 +30,8 @@
  * @method refreshProjectStat 刷新项目统计
  * @method refreshBanner 刷新轮播图
  * @method refreshKuaKeInfo 刷新夸克提交申请列表
+ * @method refreshArticle 刷新文章列表
+ * 
  */
 declare type MittType<T = any> = {
   openSetingsDrawer?: string
@@ -62,7 +64,8 @@ declare type MittType<T = any> = {
   refreshProjectStat?: T
   refreshBanner?: T
   refreshKuaKeInfo?: T
-  refreshTenantProjectPrice?:T
+  refreshTenantProjectPrice?: T
+  refreshArticle?:T
 }
 
 // mitt 参数类型定义

+ 0 - 96
src/views/admin/article/alternotice.vue

@@ -1,96 +0,0 @@
-<template>
-    <div class="my-layout">
-        <el-card class="my-fill mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
-            <el-form ref="formRef" :model="state.form" size="default" label-width="80px">
-                    <el-row :gutter="35">                      
-                      <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                          <el-form-item label="内容" prop="content" :rules="[{ required: true, message: '请输入通知内容', trigger: ['blur', 'change'] }]">                
-                            <Editor v-model:get-html="state.editor.htmlVal" v-model:get-text="state.editor.textVal" :disable="state.editor.disable" />
-                          </el-form-item>
-                        </el-col>
-                    </el-row>
-                    <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                        <el-form-item size="large">
-                            <el-button type="primary" @click="onSure" size="default" :loading="state.sureLoading">确 定</el-button>
-                        </el-form-item>
-                    </el-col>                    
-                  </el-form> 
-        </el-card>        
-    </div>
-             
-</template>
-<script lang="ts" setup name="admin/notice/alternotice">
-
-// import { stat } from 'fs'
-import { reactive, getCurrentInstance, ref, defineAsyncComponent, onMounted } from 'vue'
-import { NoticeAddInput, NoticeUpdateInput } from '/@/api/admin/data-contracts'
-import { NoticeApi } from '/@/api/admin/Notice'
-
-// 引入组件
-const Editor = defineAsyncComponent(() => import('/@/components/editor/index.vue'))
-
-
-const { proxy } = getCurrentInstance() as any
-
-
-const formRef = ref()
-
-const state = reactive({    
-    sureLoading: false,
-    form: {} as NoticeAddInput & NoticeUpdateInput,
-    editor: {
-        htmlVal: '',
-        textVal: '',
-        disable: false,
-    },
-})
-
-onMounted(() => {
-    onQuery();    
-
-})
-
-// 查询重要通知
-const onQuery = async () => {    
-    const res = await new NoticeApi().getWeight({ }, { loading: true }).catch(() => {
-        proxy.$modal.closeLoading()
-    })
-    
-    if (res?.success) {
-        if (res.data != null) {
-            state.form = res.data as NoticeAddInput & NoticeUpdateInput;
-            state.editor.htmlVal = state.form.content;
-        } else { 
-            state.form = {} as NoticeAddInput & NoticeUpdateInput
-        }
-        
-    }    
-}
-
-// 确定
-const onSure = () => {
-    if (state.editor.textVal!="")
-        state.form.content = state.editor.htmlVal;    
-    formRef.value.validate(async (valid: boolean) => {        
-        if (!valid) return        
-        state.sureLoading = true
-        state.form.isAlter = 1;
-        state.form.rank = 0;
-        state.form.title='重要通知'
-        let res = {} as any
-        if (state.form.id != undefined && state.form.id > 0) {
-            res = await new NoticeApi().update(state.form, { showSuccessMessage: true }).catch(() => {                
-                state.sureLoading = false
-            })
-        } else {
-            res = await new NoticeApi().add(state.form, { showSuccessMessage: true }).catch(() => {                
-                state.sureLoading = false
-            })
-        }
-        if (res?.success) {
-            onQuery();
-            state.sureLoading = false
-        }
-    }) 
-}
-</script>

+ 23 - 27
src/views/admin/article/components/notice-form.vue → src/views/admin/article/components/article-form.vue

@@ -17,26 +17,18 @@
             </el-form-item>
           </el-col>
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-              <el-form-item label="内容">                
+              <el-form-item label="内容" prop="contentOnly" :rules="[{ required: true, message: '请输入内容', trigger: ['blur', 'change'] }]">                
                 <Editor v-model:get-html="state.editor.htmlVal" v-model:get-text="state.editor.textVal" :disable="state.editor.disable" />
               </el-form-item>
             </el-col>                                          
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
             <el-form-item label="排序" prop="rank" placeholder="填写排序数值,越大越靠前" >
-              <el-input v-model="form.rank" autocomplete="off" />
+              <el-input type="number" v-model="form.rank" autocomplete="off" />
             </el-form-item>
-          </el-col>          
-            <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-                <el-form-item label="公告标签" prop="Tags" >
-                  <el-radio-group v-model="form.tags">
-                    <el-radio label="最新" ></el-radio>
-                    <el-radio label="重要"></el-radio>
-                  </el-radio-group>
-                </el-form-item>
-              </el-col>                                        
+          </el-col>
         </el-row>
       </el-form>
-      <template #footer>
+      <template #footer v-if="state.buttonType==0">
         <span class="dialog-footer">
           <el-button @click="onCancel" size="default">取 消</el-button>
           <el-button type="primary" @click="onSure" size="default" :loading="state.sureLoading">确 定</el-button>
@@ -46,12 +38,12 @@
   </div>
 </template>
 
-<script lang="ts" setup name="admin/notice/form">
+<script lang="ts" setup name="admin/article/form">
 
 // import { stat } from 'fs'
 import { reactive, toRefs, getCurrentInstance, ref, defineAsyncComponent } from 'vue'
-import { NoticeAddInput, NoticeUpdateInput } from '/@/api/admin/data-contracts'
-import { NoticeApi } from '/@/api/admin/Notice'
+import { AriticleAddInput, AriticleUpdateInput } from '/@/api/admin/data-contracts'
+import { AriticelApi } from '/@/api/admin/Article'
 import eventBus from '/@/utils/mitt'
 // 引入组件
 const Editor = defineAsyncComponent(() => import('/@/components/editor/index.vue'))
@@ -70,8 +62,9 @@ const { proxy } = getCurrentInstance() as any
 const formRef = ref()
 const state = reactive({
   showDialog: false,
-  sureLoading: false,  
-  form: {} as NoticeAddInput & NoticeUpdateInput, 
+  sureLoading: false, 
+  buttonType:0, 
+  form: {} as AriticleAddInput & AriticleUpdateInput, 
   editor: {
     htmlVal:'',
     textVal: '',
@@ -82,20 +75,20 @@ const { form } = toRefs(state)
 
 
 // 打开对话框
-const open = async (row: any = {}) => {  
-    
+const open = async (row: any = {},buttonType:number=0) => {  
+  state.buttonType = buttonType;
   if (row.id > 0) {
-    const res = await new NoticeApi().get({ id: row.id }, { loading: true }).catch(() => {
+    const res = await new AriticelApi().get({ id: row.id }, { loading: true }).catch(() => {
       proxy.$modal.closeLoading()
     })
 
     if (res?.success) {
-      state.form = res.data as NoticeAddInput & NoticeUpdateInput        
+      state.form = res.data as AriticleAddInput & AriticleUpdateInput        
       state.editor.htmlVal = state.form.content;      
+      state.editor.textVal = state.form.contentOnly;
     }
   } else {
-    state.form = {} as NoticeAddInput & NoticeUpdateInput
-    state.form.tags = '最新';
+    state.form = {} as AriticleAddInput & AriticleUpdateInput  
     state.editor.htmlVal = '';
     state.editor.textVal = '';    
   }
@@ -110,26 +103,29 @@ const onCancel = () => {
 
 // 确定
 const onSure = () => {
+  state.form.content = state.editor.htmlVal;
+  state.form.contentOnly = state.editor.textVal;
   formRef.value.validate(async (valid: boolean) => {
     if (!valid) return
 
-    state.form.content = state.editor.htmlVal;
+    
+
 
     state.sureLoading = true
     let res = {} as any
     if (state.form.id != undefined && state.form.id > 0) {
-      res = await new NoticeApi().update(state.form, { showSuccessMessage: true }).catch(() => {
+      res = await new AriticelApi().update(state.form, { showSuccessMessage: true }).catch(() => {
         state.sureLoading = false
       })
     } else {
-      res = await new NoticeApi().add(state.form, { showSuccessMessage: true }).catch(() => {
+      res = await new AriticelApi().add(state.form, { showSuccessMessage: true }).catch(() => {
         state.sureLoading = false
       })
     }
     state.sureLoading = false
 
     if (res?.success) {
-      eventBus.emit('refreshNotice')
+      eventBus.emit('refreshArticle')
       state.showDialog = false
     }
   })

+ 38 - 29
src/views/admin/article/index.vue

@@ -2,24 +2,30 @@
   <div class="my-layout">
     <el-card class="mt8" shadow="never" :body-style="{ paddingBottom: '0' }">
       <el-form :inline="true" @submit.stop.prevent>
+        <el-form-item>            
+          <el-input type="text" v-model="state.filter.keyword" placeholder="请输入文章标题" clearable></el-input>
+          </el-form-item>
         <el-form-item>
-          <el-button v-auth="'api:admin:notice:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增
+          <el-button type="primary" @click="onQuery"> 搜索</el-button>
+          <el-button v-auth="'api:admin:article:add'" type="primary" icon="ele-Plus" @click="onAdd"> 新增
           </el-button>
         </el-form-item>
       </el-form>
     </el-card>
 
     <el-card class="my-fill mt8" shadow="never">
-      <el-table v-loading="state.loading" :data="state.tenantListData" row-key="id" height="'100%'"
+      <el-table v-loading="state.loading" :data="state.listData" row-key="id" height="'100%'"
         style="width: 100%; height: 100%">
+        <el-table-column prop="id" label="文章ID" width="180" show-overflow-tooltip />
         <el-table-column prop="title" label="标题" min-width="120" show-overflow-tooltip />
         <el-table-column prop="createdTime" label="添加时间" width="180" show-overflow-tooltip />
         <el-table-column prop="rank" label="排序" width="120" show-overflow-tooltip />
-        <el-table-column label="操作" width="140" header-align="center" align="center" fixed="right">
+        <el-table-column label="操作" width="160" header-align="center" align="center" fixed="right">
           <template #default="{ row }">
-            <el-button v-auth="'api:admin:notice:update'" icon="ele-EditPen" size="small" text type="primary"
+            <el-button size="small" text type="primary" @click="onDetail(row)">查看</el-button>
+            <el-button v-auth="'api:admin:article:update'" icon="ele-EditPen" size="small" text type="primary"
               @click="onEdit(row)">编辑</el-button>
-              <el-button v-auth="'api:admin:notice:soft-delete'" icon="ele-Delete" size="small" text type="danger"
+              <el-button v-auth="'api:admin:article:soft-delete'" icon="ele-Delete" size="small" text type="danger"
                 @click="onDelete(row)">删除</el-button>            
           </template>
         </el-table-column>
@@ -32,78 +38,81 @@
       </div>
     </el-card>
 
-    <notice-form ref="noticeFormRef" :title="state.noticeFormTitle"></notice-form>
+    <article-form ref="AriticelFormRef" :title="state.ArticleFormTitle"></article-form>
   </div>
 </template>
 
-<script lang="ts" setup name="admin/notice/index">
+<script lang="ts" setup name="admin/article/index">
 import { ref, reactive, onMounted, getCurrentInstance, onBeforeMount, defineAsyncComponent } from 'vue'
-import { NoticeGetPageOutput, PageInputNoticeGetPageDto } from '/@/api/admin/data-contracts'
-import { NoticeApi } from '/@/api/admin/Notice'
+import { AriticleListOutput, PageInputAriticleGetPageDto } from '/@/api/admin/data-contracts'
+import { AriticelApi } from '/@/api/admin/Article'
 import eventBus from '/@/utils/mitt'
-import { auth } from '/@/utils/authFunction'
 
 // 引入组件
-const NoticeForm = defineAsyncComponent(() => import('./components/notice-form.vue'))
-const MyDropdownMore = defineAsyncComponent(() => import('/@/components/my-dropdown-more/index.vue'))
+const ArticleForm = defineAsyncComponent(() => import('./components/article-form.vue'))
 
 const { proxy } = getCurrentInstance() as any
 
-const noticeFormRef = ref()
+const AriticelFormRef = ref()
 
 const state = reactive({
   loading: false,
-  noticeFormTitle: '',
+  ArticleFormTitle: '',
   total: 0,
   filter: {
-
+    keyword:''
   },
   pageInput: {
     currentPage: 1,
     pageSize: 20,
-  } as PageInputNoticeGetPageDto,
-  tenantListData: [] as Array<NoticeGetPageOutput>,
+  } as PageInputAriticleGetPageDto,
+  listData: [] as Array<AriticleListOutput>,
 })
 
 onMounted(() => {
   onQuery()
-  eventBus.off('refreshNotice')
-  eventBus.on('refreshNotice', async () => {
+  eventBus.off('refreshArticle')
+  eventBus.on('refreshArticle', async () => {
     onQuery()
   })
 })
 
 onBeforeMount(() => {
-  eventBus.off('refreshNotice')
+  eventBus.off('refreshArticle')
 })
 
 const onQuery = async () => {
   state.loading = true
   state.pageInput.filter = state.filter
-  const res = await new NoticeApi().getPage(state.pageInput).catch(() => {
+  const res = await new AriticelApi().getPage(state.pageInput).catch(() => {
     state.loading = false
   })
 
-  state.tenantListData = res?.data?.list ?? []
+  state.listData = res?.data?.list ?? []
   state.total = res?.data?.total ?? 0
   state.loading = false
 }
 
 const onAdd = () => {
-  state.noticeFormTitle = '新增公告'
-  noticeFormRef.value.open()
+  state.ArticleFormTitle = '新增文章'
+  AriticelFormRef.value.open()
 }
 
-const onEdit = (row: NoticeGetPageOutput) => {
-  state.noticeFormTitle = '编辑公告'
-  noticeFormRef.value.open(row)
+const onEdit = (row: AriticleListOutput) => {
+  state.ArticleFormTitle = '编辑文章'
+  AriticelFormRef.value.open(row)
+}
+const onDetail = (row: AriticleListOutput) => {
+  state.ArticleFormTitle = '查看详情'
+  AriticelFormRef.value.open(row,1)
 }
 
-const onDelete = (row: NoticeGetPageOutput) => {
+
+const onDelete = (row: AriticleListOutput) => {
   proxy.$modal
     .confirmDelete(`确定要删除【${row.title}】?`)
     .then(async () => {
-      await new NoticeApi().softDelete({ id: row.id }, { loading: true, showSuccessMessage: true })
+      await new AriticelApi().softDelete({ id: row.id }, { loading: true, showSuccessMessage: true })
       onQuery()
     })
     .catch(() => { })