Commit e05b6574 authored by 前端-李俊鑫's avatar 前端-李俊鑫

fix: 内容能力相关问题

parent af110b65
......@@ -15,6 +15,7 @@ import CustomCheckbox from '../components/CustomCheckbox';
import BraftEditor from 'braft-editor';
import { setFormStatus } from '../utils/utils';
import useCustomValidator from '../hooks/useValidator'
import styles from '../index.less'
const actions = createFormActions();
......@@ -81,14 +82,7 @@ const AdvertisementInfo = () => {
editable={isAdd || isEdit}
expressionScope={{
label: (
<div>
{
isAdd || isEdit
? <span style={{color: '#ff4d4f'}}>* </span>
: null
}
栏目
</div>
<div className={styles.custom_label}>栏目</div>
)
}}
>
......
......@@ -4,6 +4,7 @@ import { Card, Select, Input, Button } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ReutrnEle from '@/components/ReturnEle';
import { usePageStatus } from '@/hooks/usePageStatus';
import { validatorAllTrim } from '@/utils/regExp';
import { history, Prompt } from 'umi';
import { PublicApi } from '@/services/api';
import useCustomValidator from '../hooks/useValidator'
......@@ -51,6 +52,10 @@ const schema = {
{
limitByte: true, // 自定义校验规则
maxByte: 20,
},
{
validator: value => value.trim().length === 0,
message: '栏目名称不可为空',
}
]
},
......
.custom_label {
position: relative;
font-size: 12px;
color: #909399;
&::after {
position: absolute;
display: inline-block;
margin-right: 4px;
color: #ff4d4f;
font-size: 12px;
font-family: SimSun, sans-serif;
line-height: 1;
content: '*';
top: 4px;
right: -22px;
}
}
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useRef } from 'react';
import { FilterTable, SchemaFlexRowLayout, SchemaFlexColumnLayout } from '../components/FilterTable';
import { Card, Input, Button, Table, Dropdown, Menu, Select, Space, Modal, Popconfirm } from 'antd';
import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd';
......@@ -15,11 +15,6 @@ import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
const { onFormInit$, onFieldValueChange$ } = FormEffectHooks
const { Search } = Input;
const SchemaButton = createVirtualBox('button', Button);
const SchemaTable = createVirtualBox('SchemaTable', Table);
const SchemaDropDown = createVirtualBox('SchemaDropDown', Dropdown.Button);
const actions = createFormActions();
......@@ -34,31 +29,16 @@ interface optionsType {
value: string | number
}
const useGetColumns = () => {
const [state, setState] = useState<optionsType[]>([]);
useEffect(() => {
async function getAllColumns() {
const res = await PublicApi.getManageMemberColumnAll();
console.log(res);
const options = res.data.map((item) => ({label: item.name, value: item.id}));
// setTableStatus("column", "options", options);
setState(options)
}
getAllColumns();
}, [])
return state;
}
const getData = async (params: any) => {
const res = await PublicApi.getManageMemberInformationPage(params);
return res.data
}
const Infomation = () => {
const columns = useGetColumns();
const [selectedRow, setSelectedRow] = useState<any[]>([]);
// const [roleSelection, roleSelectCtl] = useRowSelectionTable()
// const refkeys = useRef([])
const selectedRowRef = useRef<any[]>([])
const columnsOptionsRef = useRef<any[]>([])
useEffect(() => {
const params = {
......@@ -68,6 +48,16 @@ const Infomation = () => {
getTableDataSource(actions, params, getData);
}, [])
useEffect(() => {
PublicApi.getManageMemberColumnAll().then((res) => {
const { code, data } = res
console.log(res);
if (code === 1000) {
columnsOptionsRef.current = data.map((item) => ({label: item.name, value: item.id}));
}
});
}, [])
const infomationEffects = () => () => {
onFormInit$().subscribe(() => {
actions.setFieldState('FILTERS', state => {
......@@ -121,12 +111,13 @@ const Infomation = () => {
// 批量删除
const batchDelete = () => {
const rows = selectedRow
const rows = selectedRowRef.current
handleBatch(rows, 1);
}
// type 1-批量删除 2-批量上架 3-批量下架
const handleBatch = (row, type) => {
console.log(`handleBatch type`, type)
PublicApi.postManageMemberInformationBatch({ids: row, type: type})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
......@@ -231,12 +222,12 @@ const Infomation = () => {
batchGrounding: () => {
console.log("批量上架");
const rows = selectedRow
const rows = selectedRowRef.current
handleBatch(rows, 2);
},
undercarriage: () => {
console.log("批量下架")
const rows = selectedRow
const rows = selectedRowRef.current
handleBatch(rows, 3);
},
menu: () => {
......@@ -269,15 +260,18 @@ const Infomation = () => {
keys = keys.filter((_item) => _item !== record.id);
}
setSelectedRow(keys)
selectedRowRef.current = keys
},
onSelectAll: (selected, checkedRows, changeRows) => {
const changeRowKey = changeRows.filter((_item) => _item).map((item) => item.id);
let keys = Array.from(new Set([...changeRowKey, ...selectedRow]))
if(selected) {
setSelectedRow(keys)
selectedRowRef.current = keys
} else {
const removeKeys = keys.filter((_item) => !changeRowKey.includes(_item));
setSelectedRow(removeKeys)
selectedRowRef.current = removeKeys
}
},
selectedRowKeys: selectedRow
......@@ -287,7 +281,7 @@ const Infomation = () => {
const visible = !state.visible;
state.visible = visible;
if(visible) {
setFormStatus(actions, 'columns', "options", columns);
setFormStatus(actions, 'columns', "options", columnsOptionsRef.current);
}
actions.setFieldState('HIGHT_FILTER_BTN', (state) => {
//@ts-ignore
......@@ -296,7 +290,6 @@ const Infomation = () => {
)
})
});
},
}}
effects={infomationEffects()}
......
......@@ -15,6 +15,8 @@ import infomationInfoSchema from './schema/infomationInfoSchema';
import CustomUpload from '../components/WrapCustomUpload';
import useCustomValidator from '../hooks/useValidator'
import { COLUMN_CATEGORY } from '../constant';
import cx from 'classnames';
import styles from '../index.less'
const actions = createFormActions();
const { onFieldValueChange$, onFieldInputChange$ } = FormEffectHooks
......@@ -221,12 +223,7 @@ const InfomationInfo = () => {
setLabelIds(value);
},
label: (
<div>
{
(isAdd || isEdit) && [1, 2, 3, 4, 6].includes(recommendLabelValue)
? <span style={{color: '#ff4d4f'}}>* </span>
: null
}
<div className={cx((isAdd || isEdit) && [1, 2, 3, 4, 6].includes(recommendLabelValue) && styles.custom_label)}>
图片
</div>
)
......
......@@ -226,17 +226,17 @@ const schema = {
title: '摘要',
"x-component": 'TextArea',
"x-component-props": {
placeholder: "最长300个字符,150个汉字",
placeholder: "最长400个字符,200个汉字",
rows: 5,
},
"x-rules": [
{
"required": true,
"message": "最长300个字符,150个汉字"
"message": "最长400个字符,200个汉字"
},
{
limitByte: true,
maxByte: 300
maxByte: 400
}
],
},
......
......@@ -10,7 +10,7 @@
// 500 error
// .wrapper{
// }
.errorBox{
width: 100%;
......@@ -27,4 +27,5 @@
.white-wrap {
background: #fff;
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment