Ver código fonte

增加评分的显示和隐藏

shaogen1995 8 horas atrás
pai
commit
3b468d6fb4

+ 12 - 0
后台管理/src/pages/A1works/A1add/index.module.scss

@@ -12,6 +12,18 @@
     .ant-form {
       width: 800px;
 
+      .A1oneText textarea {
+        min-height: 50px !important;
+      }
+      .ant-form-item-label {
+        width: 100px;
+      }
+
+      .A1AformRow {
+        display: flex;
+        justify-content: space-between;
+      }
+
       .A1fromRow {
         position: relative;
         width: 800px;

+ 21 - 12
后台管理/src/pages/A1works/A1add/index.tsx

@@ -1,6 +1,6 @@
 import React, { useCallback, useEffect, useRef, useState } from 'react'
 import styles from './index.module.scss'
-import { Button, Form, FormInstance, Input, InputNumber, Select } from 'antd'
+import { Button, Form, FormInstance, Input, InputNumber, Radio, Select } from 'antd'
 import { MessageFu } from '@/utils/message'
 import { A1_APIgetFileList, A1_APIsave } from '@/store/action/A1works'
 import { A1SelectData, A1tableType } from '../data'
@@ -48,7 +48,7 @@ function A1add({ type, closeFu, addTableFu, upTableFu, info }: Props) {
 
   useEffect(() => {
     if (info.id > 0) getInfoFu(info.id)
-    else FormBoxRef.current?.setFieldsValue({ type, sort: 999 })
+    else FormBoxRef.current?.setFieldsValue({ type, sort: 999, display: 1 })
   }, [getInfoFu, info.id, type])
 
   // 附件 是否 已经点击过确定
@@ -98,7 +98,6 @@ function A1add({ type, closeFu, addTableFu, upTableFu, info }: Props) {
       <Form
         ref={FormBoxRef}
         name='basic'
-        labelCol={{ span: 3 }}
         onFinish={onFinish}
         onFinishFailed={onFinishFailed}
         autoComplete='off'
@@ -109,18 +108,28 @@ function A1add({ type, closeFu, addTableFu, upTableFu, info }: Props) {
           name='name'
           rules={[{ required: true, message: '请输入作品名称' }]}
           // getValueFromEvent={(e) => e.target.value.replace(/\s+/g, "")}
-          getValueFromEvent={e => e.target.value.trim()}
+          // getValueFromEvent={e => e.target.value.trim()}
         >
-          <Input maxLength={30} showCount placeholder='请输入内容' />
+          <TextArea className='A1oneText' maxLength={50} showCount placeholder='请输入内容' />
         </Form.Item>
 
-        <Form.Item
-          label='所属单元'
-          name='type'
-          rules={[{ required: true, message: '请选择所属单元' }]}
-        >
-          <Select placeholder='请选择' style={{ width: 149 }} options={A1SelectData} />
-        </Form.Item>
+        <div className='A1AformRow'>
+          <Form.Item
+            label='所属单元'
+            name='type'
+            rules={[{ required: true, message: '请选择所属单元' }]}
+          >
+            <Select placeholder='请选择' style={{ width: 149 }} options={A1SelectData} />
+          </Form.Item>
+          <Form.Item label='展示评分' name='display'>
+            <Radio.Group
+              options={[
+                { value: 1, label: '展示' },
+                { value: 0, label: '隐藏' }
+              ]}
+            />
+          </Form.Item>
+        </div>
 
         <Form.Item label='创作时间' name='time'>
           <Input maxLength={30} showCount placeholder='请输入内容' />

+ 1 - 0
后台管理/src/pages/A1works/data.ts

@@ -14,6 +14,7 @@ export type A1tableType = {
   time: string
   type: string
   updateTime: string
+  display: 0 | 1
 }
 export type A1FromDataType = {
   pageNum: number

+ 14 - 10
后台管理/src/pages/A1works/index.tsx

@@ -66,17 +66,21 @@ function A1works() {
       {
         title: '当前评分',
         render: (item: A1tableType) =>
-          item.count === 0 ? (
-            '暂无评分'
+          item.display === 1 ? (
+            item.count === 0 ? (
+              '暂无评分'
+            ) : (
+              <>
+                <div className='A1tableFen'>
+                  <Rate disabled defaultValue={item.score || 0} />
+                  <p onClick={() => setScore({ id: item.id, num: item.score || 0 })}>
+                    {item.count}人评分
+                  </p>
+                </div>
+              </>
+            )
           ) : (
-            <>
-              <div className='A1tableFen'>
-                <Rate disabled defaultValue={item.score || 0} />
-                <p onClick={() => setScore({ id: item.id, num: item.score || 0 })}>
-                  {item.count}人评分
-                </p>
-              </div>
-            </>
+            '隐藏评分'
           )
       },
       {