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

fix: 修改内容能力api引入方式

parent 1a612000
......@@ -9,20 +9,20 @@ import announceInfoSchema from './schema/announceInfoSchema';
import { Input, Select } from 'antd';
import CustomUpload from '@/components/NiceForm/components/CustomUpload';
import CustomEditor from '../components/CustomEditor';
import { PublicApi } from '@/services/api';
import { useInitialValues } from '../hooks/useInitialValues';
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'
import { getManageMemberNoticeGet, postManageMemberNoticeAdd, postManageMemberNoticeUpdate } from '@/services/ManageV2Api';
const actions = createFormActions();
const AdvertisementInfo = () => {
useCustomValidator();
const { id, preview } = usePageStatus();
const initialValues: any = useInitialValues({id:id}, PublicApi.getManageMemberNoticeGet);
const initialValues: any = useInitialValues({id:id}, getManageMemberNoticeGet);
const [submitLoading, setSubmitLoading ] = useState(false);
const [unsaved, setUnsaved] = useState(true);
const isEdit = id && !preview;
......@@ -45,8 +45,8 @@ const AdvertisementInfo = () => {
const editorContent = content.toHTML();
// const { title, columnType, sort, link, imageUrl} = value;
const serviceActions = isAdd
? PublicApi.postManageMemberNoticeAdd
: PublicApi.postManageMemberNoticeUpdate
? postManageMemberNoticeAdd
: postManageMemberNoticeUpdate
let tempData = {...rest, content: editorContent, top: top ? 1 : 0};
const postData = isAdd ? tempData : {...tempData, id};
......
......@@ -5,7 +5,6 @@ import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook
import { history, Link } from 'umi';
import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons';
import { timeRange } from '@/utils/index';
import { PublicApi } from '@/services/api';
import { tagColorStyle, getTableDataSource } from '../utils/utils';
import { merge } from 'rxjs'
import TablePagination from '../components/TablePagination';
......@@ -20,9 +19,10 @@ const SchemaDropDown = createVirtualBox('SchemaDropDown', Dropdown.Button);
const actions = createFormActions();
import advertisementSchema from './schema';
import { getManageMemberNoticePage, postManageMemberNoticeDelete, postManageMemberNoticeUpdateStatus } from '@/services/ManageV2Api';
const getData = async (params: any) => {
const res = await PublicApi.getManageMemberNoticePage(params);
const res = await getManageMemberNoticePage(params);
return res.data
}
......@@ -84,7 +84,7 @@ const Announcements = () => {
Modal.confirm({
title: '确定要执行这个操作?',
onOk: () => {
PublicApi.postManageMemberNoticeDelete({id: id})
postManageMemberNoticeDelete({id: id})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
......@@ -97,7 +97,7 @@ const Announcements = () => {
// 修改状态
const handleUpdateStatus = (id, status) => {
// 该方法是上下架 所以 enableStatus 无用,随意传
PublicApi.postManageMemberNoticeUpdateStatus({id: id, shelfStatus: status, enableStatus: 0})
postManageMemberNoticeUpdateStatus({id: id, shelfStatus: status, enableStatus: 0})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
......
......@@ -6,11 +6,11 @@ import TabTree, { useTreeActions, createTreeActions } from '@/components/TabTree
import SchemaForm, { createFormActions, LifeCycleTypes, FormEffectHooks, FormButtonGroup } from '@formily/antd';
import { Checkbox } from '@formily/antd-components'
import { classSchema } from './schema'
import { PublicApi } from '@/services/api';
import { useTreeTabs } from '@/hooks/useTreeTabs';
import NiceForm from '@/components/NiceForm';
import styles from './index.less';
import { BorderOuterOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import { getManageMemberCategoryAll, getManageMemberCategoryGet, postManageMemberCategoryAdd, postManageMemberCategoryDelete, postManageMemberCategoryUpdate } from '@/services/ManageV2Api';
const { ON_FORM_INPUT_CHANGE } = LifeCycleTypes
......@@ -63,7 +63,7 @@ const formActions = createFormActions()
const treeActions = createTreeActions()
const fetchClassTreeData = async (params?) => {
const res = await PublicApi.getManageMemberCategoryAll();
const res = await getManageMemberCategoryAll();
return res
}
......@@ -85,9 +85,9 @@ const ClassProperty: React.FC<{}> = () => {
} = useTreeTabs({
treeActions,
formActions,
deleteMenu: PublicApi.postManageMemberCategoryDelete,
deleteMenu: postManageMemberCategoryDelete,
fetchMenuData: fetchClassTreeData,
fetchItemDetailData: PublicApi.getManageMemberCategoryGet
fetchItemDetailData: getManageMemberCategoryGet
})
const tempCheckedKeys = []
const transferTreeDatarRes: TreeDataType[] = useMemo(() => transferTreeData(treeData, "", tempCheckedKeys), [treeData])
......@@ -121,7 +121,7 @@ const ClassProperty: React.FC<{}> = () => {
if (nodeRecord && !isEdit && is3Level === 4) {
parentId = _key[1]
}
const service = !isEdit ? PublicApi.postManageMemberCategoryAdd : PublicApi.postManageMemberCategoryUpdate;
const service = !isEdit ? postManageMemberCategoryAdd : postManageMemberCategoryUpdate;
let postData: any = {
name: values.name,
describe: values.describe,
......
......@@ -6,8 +6,8 @@ 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'
import { getManageMemberColumnGet, postManageMemberColumnAdd, postManageMemberColumnUpdate } from '@/services/ManageV2Api';
interface IOption {
value: number|string,
......@@ -98,7 +98,7 @@ const useInitialValues = (id) => {
const [state, setState] = useState({})
useEffect(() => {
if(id) {
PublicApi.getManageMemberColumnGet({id: id})
getManageMemberColumnGet({id: id})
.then((data) => {
setState(data);
})
......@@ -120,8 +120,8 @@ const ColumnInfo = () => {
const handleSubmit = async (value: { name: string, sort: number, type: number }) => {
const { name, sort, type} = value;
const serviceActions = isAdd
? PublicApi.postManageMemberColumnAdd
: PublicApi.postManageMemberColumnUpdate
? postManageMemberColumnAdd
: postManageMemberColumnUpdate
const postData = {id, name, sort, type};
setSubmitLoading(true)
......
......@@ -2,7 +2,6 @@ import React, { useEffect, useState, useRef } from 'react';
import { Card, Button, Popconfirm, Row, Col } from 'antd';
import { createFormActions } from '@formily/antd';
import { history, Link } from 'umi';
import { PublicApi } from '@/services/api';
import StatusSwitch from '@/components/StatusSwitch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PlusOutlined } from '@ant-design/icons'
......@@ -14,12 +13,13 @@ import EyePreview from '@/components/EyePreview'
import { ISchema } from '@formily/antd';
import { StandardTable } from 'god'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { getManageMemberColumnPage, postManageMemberColumnDelete, postManageMemberColumnUpdateStatus } from '@/services/ManageV2Api';
const formActions = createFormActions();
const actions = createFormActions();
const getData = async (params) => {
const res = await PublicApi.getManageMemberColumnPage(params)
const res = await getManageMemberColumnPage(params)
return res.data
}
......@@ -74,16 +74,17 @@ const columnList: React.FC<{}> = () => {
// 停用/启用
const handleModify = async (record: any) => {
await PublicApi.postManageMemberColumnUpdateStatus({
await postManageMemberColumnUpdateStatus({
id: record.id,
enableStatus: record.status === 1 ? 0 : 1
enableStatus: record.status === 1 ? 0 : 1,
shelfStatus: undefined,
})
ref.current.reload()
}
// 栏目删除
const handleRemove = async (id: number) => {
const res = await PublicApi.postManageMemberColumnDelete({ id })
const res = await postManageMemberColumnDelete({ id })
if (res.code === 1000) {
ref.current.reload()
}
......@@ -92,7 +93,7 @@ const columnList: React.FC<{}> = () => {
// 获取列表
const fetchData = (params: any) => {
return new Promise((resolve) => {
PublicApi.getManageMemberColumnPage(params).then(res => {
getManageMemberColumnPage(params).then(res => {
resolve(res.data)
})
})
......
......@@ -5,13 +5,13 @@ import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook
import { history, Link } from 'umi';
import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons';
import { timeRange } from '@/utils/index';
import { PublicApi } from '@/services/api';
import { infomationSchema } from './schema';
import TablePagination from '../components/TablePagination';
import { getTableDataSource, setFormStatus } from '../utils/utils'
import { merge } from 'rxjs';
import CustomSearch from '../components/CustomSearch';
import { useRowSelectionTable } from '@/hooks/useRowSelectionTable';
import { getManageMemberColumnAll, getManageMemberInformationPage, postManageMemberInformationBatch, postManageMemberInformationDelete, postManageMemberInformationUpdateStatus } from '@/services/ManageV2Api';
const { onFormInit$, onFieldValueChange$ } = FormEffectHooks
......@@ -30,7 +30,7 @@ interface optionsType {
}
const getData = async (params: any) => {
const res = await PublicApi.getManageMemberInformationPage(params);
const res = await getManageMemberInformationPage(params);
return res.data
}
......@@ -49,7 +49,7 @@ const Infomation = () => {
}, [])
useEffect(() => {
PublicApi.getManageMemberColumnAll().then((res) => {
getManageMemberColumnAll().then((res) => {
const { code, data } = res
console.log(res);
if (code === 1000) {
......@@ -102,7 +102,7 @@ const Infomation = () => {
// 修改状态
const handleUpdateState = (id, status) => {
// 该方法是上下架 所以 enableStatus 无用,随意传
PublicApi.postManageMemberInformationUpdateStatus({id: id, shelfStatus: status, enableStatus: 0})
postManageMemberInformationUpdateStatus({id: id, shelfStatus: status, enableStatus: 0})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
......@@ -118,7 +118,7 @@ const Infomation = () => {
// type 1-批量删除 2-批量上架 3-批量下架
const handleBatch = (row, type) => {
console.log(`handleBatch type`, type)
PublicApi.postManageMemberInformationBatch({ids: row, type: type})
postManageMemberInformationBatch({ids: row, type: type})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
......@@ -129,7 +129,7 @@ const Infomation = () => {
Modal.confirm({
title: '确定要执行这个操作?',
onOk: () => {
PublicApi.postManageMemberInformationDelete({id: id})
postManageMemberInformationDelete({id: id})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
......
......@@ -10,13 +10,13 @@ import { CustomTags } from '../components/Tags';
import CustomEditor from '../components/CustomEditor';
import BraftEditor from 'braft-editor';
import { useInitialValues } from '../hooks/useInitialValues';
import { PublicApi } from '@/services/api';
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'
import { getManageMemberCategoryAll, getManageMemberColumnAll, getManageMemberInformationGet, getManageMemberLabelAll, postManageMemberInformationAdd, postManageMemberInformationUpdate } from '@/services/ManageV2Api';
const actions = createFormActions();
const { onFieldValueChange$, onFieldInputChange$ } = FormEffectHooks
......@@ -43,7 +43,7 @@ const InfomationInfo = () => {
const [submitLoading, setSubmitLoading ] = useState(false);
const [unsaved, setUnsaved] = useState(true);
const [type, setType] = useState<ColumnType>(0);
const initialValues = useInitialValues({id:id}, PublicApi.getManageMemberInformationGet);
const initialValues = useInitialValues({id:id}, getManageMemberInformationGet);
const [category, setCategory] = useState<any>([]);
const [column, setColumn] = useState<ColumnListType[]>([])
const [recommendLabelValue, setRecommendLabelValue] = useState<number>();
......@@ -62,7 +62,7 @@ const InfomationInfo = () => {
useEffect(() => {
async function getColumn() {
const res = await PublicApi.getManageMemberColumnAll();
const res = await getManageMemberColumnAll();
const list = res.data.map((item) => ({label: item.name, value: item.id, type: item.type}));
setFormStatus("layout.columnId", "options", list)
setColumn(list)
......@@ -72,7 +72,7 @@ const InfomationInfo = () => {
useEffect(() => {
async function getLabels() {
const res = await PublicApi.getManageMemberLabelAll();
const res = await getManageMemberLabelAll();
const labels = res.data.map((item) => ({label: item.name, value: item.id}));
setFormStatus("layout.labelIds", "dataSource", labels)
}
......@@ -84,7 +84,7 @@ const InfomationInfo = () => {
*/
useEffect(() => {
async function getCategory() {
const { data, code, message } = await PublicApi.getManageMemberCategoryAll();
const { data, code, message } = await getManageMemberCategoryAll();
if (code !== 1000) return;
const list = data.map((_item) => ({ label: _item.name, value: _item.id, children: _item.list }) );
setFormStatus("layout.categoryLayout.firstCategoryId", "options", list);
......@@ -142,8 +142,8 @@ const InfomationInfo = () => {
content: content,
}
const serviceActions = isAdd
? PublicApi.postManageMemberInformationAdd
: PublicApi.postManageMemberInformationUpdate
? postManageMemberInformationAdd
: postManageMemberInformationUpdate
const postData = isAdd ? tempPostData : {...tempPostData, id: id};
console.log(`postData`, postData)
......
......@@ -3,12 +3,12 @@ import { Card, Input, Button, Table, Space, Popconfirm } from 'antd';
import { FilterTable, SchemaFlexRowLayout } from '../components/FilterTable';
import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd';
import { history, Link } from 'umi';
import { PublicApi } from '@/services/api';
import StatusSwitch from '@/components/StatusSwitch';
import tagsManagementSchema from './schema';
import TablePagination from '../components/TablePagination';
import { getTableDataSource } from '../utils/utils';
import CustomSearch from '../components/CustomSearch';
import { getManageMemberLabelPage, postManageMemberLabelDelete, postManageMemberLabelUpdateStatus } from '@/services/ManageV2Api';
const { onFieldValueChange$ } = FormEffectHooks
......@@ -18,7 +18,7 @@ const SchemaTable = createVirtualBox('SchemaTable', Table);
const actions = createFormActions();
const getData = async (params) => {
const res = await PublicApi.getManageMemberLabelPage(params)
const res = await getManageMemberLabelPage(params)
return res.data
}
......@@ -36,37 +36,36 @@ const Tags = () => {
}
getTableDataSource(actions, params, getData);
}, [])
// 修改状态
const handleModify = (value) => {
const { id, status } = value;
const { id, status } = value;
const postData = {
id: id,
id: id,
enableStatus: (status ^ 1),
}
//@ts-ignore
PublicApi.postManageMemberLabelUpdateStatus(postData).
postManageMemberLabelUpdateStatus(postData).
then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
})
}
}
// 栏目删除
const handleRemove = (id: number) => {
///manage/contentColumn/delete
PublicApi.postManageMemberLabelDelete({id: id})
postManageMemberLabelDelete({id: id})
.then(async (data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
})
}
const handleSearch = async (params) => {
const title = actions.getFieldValue('search');
const postData = {
name: title || '',
current: 1,
current: 1,
pageSize: 10,
...params,
}
......@@ -84,7 +83,7 @@ const Tags = () => {
return (
<div>
<Card>
<FilterTable
<FilterTable
effects={tagEffects()}
schema={tagsManagementSchema}
components={{CustomSearch, TablePagination}}
......@@ -139,4 +138,4 @@ const Tags = () => {
)
}
export default Tags
\ No newline at end of file
export default Tags
......@@ -6,8 +6,8 @@ import ReutrnEle from '@/components/ReturnEle';
import { usePageStatus } from '@/hooks/usePageStatus';
import { history, Prompt } from 'umi';
import { useInitialValues } from '../hooks/useInitialValues';
import { PublicApi } from '@/services/api';
import useCustomValidator from '../hooks/useValidator'
import { getManageMemberLabelGet, postManageMemberLabelAdd, postManageMemberLabelUpdate } from '@/services/ManageV2Api';
const { TextArea } = Input;
const schema = {
......@@ -35,7 +35,7 @@ const schema = {
},
{
limitByte: true, // 自定义校验规则
maxByte: 20,
maxByte: 20,
}
],
},
......@@ -49,7 +49,7 @@ const schema = {
"x-rules": [
{
limitByte: true, // 自定义校验规则
maxByte: 80,
maxByte: 80,
}
],
},
......@@ -64,7 +64,7 @@ const TagInfo = () => {
useCustomValidator();
const { id, preview } = usePageStatus();
const [ submitLoading, setSubmitLoading ] = useState(false);
const initialValues = useInitialValues({id:id}, PublicApi.getManageMemberLabelGet);
const initialValues = useInitialValues({id:id}, getManageMemberLabelGet);
const isEdit = id && !preview;
const isAdd = !id && !preview;
const [unsaved, setUnsaved] = useState(true);
......@@ -72,9 +72,9 @@ const TagInfo = () => {
console.log(value)
const { id, name, explain} = value;
const serviceActions = isAdd
? PublicApi.postManageMemberLabelAdd
: PublicApi.postManageMemberLabelUpdate
? postManageMemberLabelAdd
: postManageMemberLabelUpdate
let tempData = {name, explain};
const postData = isAdd ? {...tempData, id: 0} : {...tempData, id};
setSubmitLoading(true)
......@@ -98,7 +98,7 @@ const TagInfo = () => {
title={!id ? '新建标签' : '编辑标签'}
>
<Card>
<SchemaForm
<SchemaForm
initialValues={initialValues?.data}
onSubmit={handleSubmit}
editable={isAdd || isEdit}
......@@ -106,12 +106,12 @@ const TagInfo = () => {
components={{ Input, Select, Submit, TextArea }}
>
{
isAdd || isEdit
isAdd || isEdit
? (
<FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit>
<Button onClick={handleCancel}>取消</Button>
</FormButtonGroup>
</FormButtonGroup>
)
: <></>
}
......@@ -123,4 +123,4 @@ const TagInfo = () => {
)
}
export default TagInfo
\ No newline at end of file
export default TagInfo
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