Commit 3f822489 authored by Bill's avatar Bill

fix: 修改内容管理禁用视频上传,修改图片上传组件,允许preview

parent 45f17881
......@@ -54,12 +54,20 @@
top: 0;
border-radius: 2px;
.container {
display: flex;
flex-direction: row;
height: 100%;
align-items: center;
justify-content: center;
}
.delete_btn {
color: #fff;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
}
.view_btn {
color: #fff;
}
}
......@@ -75,4 +83,4 @@
}
}
}
\ No newline at end of file
}
import React, { useState, Fragment, forwardRef, Children } from 'react'
import { Upload, message, Button } from 'antd'
import { LoadingOutlined, PlusOutlined, DeleteOutlined } from '@ant-design/icons'
import { Upload, message, Button, Modal } from 'antd'
import { LoadingOutlined, PlusOutlined, DeleteOutlined, EyeOutlined} from '@ant-design/icons'
import { UploadFile, UploadChangeParam } from 'antd/lib/upload/interface';
import { UPLOAD_TYPE } from '@/constants/index';
import cx from 'classnames'
......@@ -20,6 +20,7 @@ interface UploadImagePorpsType {
const UploadImage: React.FC<UploadImagePorpsType> = forwardRef((props, ref) => {
const { children, imgUrl, onChange, showDesc = true, size = "386x256", disabled = false, large = false, fileMaxSize = 200, listType = "picture-card" } = props
const [loading, setLoading] = useState<boolean>(false)
const [visible, setVisible] = useState(false);
const beforeUpload = (file: UploadFile) => {
const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png' || file.type === 'image/jpg' || file.type === 'image/gif';
if (!isJpgOrPng) {
......@@ -70,6 +71,10 @@ const UploadImage: React.FC<UploadImagePorpsType> = forwardRef((props, ref) => {
</Fragment>
);
const handleToggle = (flag: boolean) => {
setVisible(flag)
}
const renderUploadComponentByListType = () => {
switch(listType) {
case "picture-card":
......@@ -84,7 +89,13 @@ const UploadImage: React.FC<UploadImagePorpsType> = forwardRef((props, ref) => {
</div>}
</Upload>
{
imgUrl && <div className={styles.delete_wrap}><Button onClick={clearImage} className={styles.delete_btn} type="text" icon={<DeleteOutlined />} /></div>
imgUrl && (
<div className={styles.delete_wrap}>
<div className={styles.container}>
<a className={styles.view_btn} onClick={() => handleToggle(true)}><EyeOutlined /></a>
<Button onClick={clearImage} className={styles.delete_btn} type="text" icon={<DeleteOutlined />} />
</div>
</div>)
}
</div>
{
......@@ -107,7 +118,21 @@ const UploadImage: React.FC<UploadImagePorpsType> = forwardRef((props, ref) => {
}
return renderUploadComponentByListType()
return (
<div>
{
renderUploadComponentByListType()
}
<Modal
visible={visible}
title={""}
footer={null}
onCancel={() => handleToggle(false)}
>
<img style={{ width: '100%' }} src={imgUrl} />
</Modal>
</div>
)
})
UploadImage.displayName = "UploadImage"
......
......@@ -128,7 +128,7 @@ const AdvertisementInfo = () => {
: <></>
}
</SchemaForm>
<Prompt when={unsaved} message="内容未保存,确定离开?"></Prompt>
<Prompt when={unsaved && (isAdd || isEdit)} message="内容未保存,确定离开?"></Prompt>
</Card>
</PageHeaderWrapper>
)
......
......@@ -15,7 +15,7 @@ import CustomCheckbox from '../components/CustomCheckbox';
import BraftEditor from 'braft-editor';
import { setFormStatus } from '../utils/utils';
import useCustomValidator from '../hooks/useValidator'
const actions = createFormActions();
const AdvertisementInfo = () => {
......@@ -46,7 +46,7 @@ const AdvertisementInfo = () => {
const serviceActions = isAdd
? PublicApi.postManageContentNoticeAdd
: PublicApi.postManageContentNoticeUpdate
let tempData = {...rest, content: editorContent, top: top ? 1 : 0};
const postData = isAdd ? tempData : {...tempData, id};
setSubmitLoading(true)
......@@ -83,7 +83,7 @@ const AdvertisementInfo = () => {
label: (
<div>
{
isAdd || isEdit
isAdd || isEdit
? <span style={{color: '#ff4d4f'}}>* </span>
: null
}
......@@ -93,20 +93,20 @@ const AdvertisementInfo = () => {
}}
>
{
isAdd || isEdit
isAdd || isEdit
? (
<FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit>
<Button onClick={handleCancel}>取消</Button>
</FormButtonGroup>
</FormButtonGroup>
)
: <></>
}
</SchemaForm>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?"></Prompt>
<Prompt when={unsaved && (isAdd || isEdit)} message="您还有未保存的内容,是否确定要离开?"></Prompt>
</Card>
</PageHeaderWrapper>
)
}
export default AdvertisementInfo
\ No newline at end of file
export default AdvertisementInfo
......@@ -27,7 +27,7 @@ const schema = {
},
{
limitByte: true, // 自定义校验规则
maxByte: 60,
maxByte: 60,
}
]
},
......@@ -36,7 +36,7 @@ const schema = {
'x-component': 'mega-layout',
"x-component-props": {
"label": "{{label}}",
wrapperCol: 24, //
wrapperCol: 24, //
grid: true,
columns: 6,
autoRow: false,
......@@ -118,7 +118,14 @@ const schema = {
'superscript',
'subscript',
'hr',
]
],
media: {
// 如果要允许上传视频的话,需要重写uploadFn, https://www.yuque.com/braft-editor/be/gz44tn
accepts: {
video: false,
audio: false,
}
}
},
}
}
......@@ -128,4 +135,4 @@ const schema = {
}
}
export default schema
\ No newline at end of file
export default schema
......@@ -50,7 +50,7 @@ const schema = {
},
{
limitByte: true, // 自定义校验规则
maxByte: 20,
maxByte: 20,
}
]
},
......@@ -81,7 +81,7 @@ const useInitialValues = (id) => {
setState(data);
})
}
}, [id])
return state
}
......@@ -100,7 +100,7 @@ const ColumnInfo = () => {
const serviceActions = isAdd
? PublicApi.postManageContentColumnAdd
: PublicApi.postManageContentColumnUpdate
const postData = {id, name, sort};
setSubmitLoading(true)
setUnsaved(false)
......@@ -124,7 +124,7 @@ const ColumnInfo = () => {
title={!id ? '新建栏目' : '编辑栏目'}
>
<Card>
<SchemaForm
<SchemaForm
initialValues={initialValues?.data}
onSubmit={handleSubmit}
editable={isAdd || isEdit}
......@@ -132,22 +132,22 @@ const ColumnInfo = () => {
components={{ Input, Select, Submit }}
>
{
isAdd || isEdit
isAdd || isEdit
? (
<FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit>
<Button onClick={handleCancel}>取消</Button>
</FormButtonGroup>
</FormButtonGroup>
)
: <></>
}
</SchemaForm>
</Card>
</PageHeaderWrapper>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
<Prompt when={unsaved && (isAdd || isEdit)} message="您还有未保存的内容,是否确定要离开?" />
</div>
)
}
export default ColumnInfo
\ No newline at end of file
export default ColumnInfo
......@@ -6,7 +6,7 @@ import BraftEditor from 'braft-editor';
// const SchemaEditor = createVirtualBox('SchemaEditor', BraftEditor);
const CustomEditor = (props) => {
const editorProps = props.props['x-component-props'];
const parentProps = props.props['x-component-parent-props'];
const parentProps = props.props['x-component-parent-props'];
const handleChange = (editorState) => {
const isEmpty = editorState.isEmpty();
......@@ -23,4 +23,4 @@ const CustomEditor = (props) => {
CustomEditor.isFieldComponent = true;
export default CustomEditor
\ No newline at end of file
export default CustomEditor
......@@ -33,7 +33,7 @@ const ImageInfo = () => {
const serviceActions = isAdd
? PublicApi.postManageContentImageAdd
: PublicApi.postManageContentImageUpdate
let tempData = value;
const postData = isAdd ? tempData : {...tempData, id};
setSubmitLoading(true)
......@@ -52,17 +52,17 @@ const ImageInfo = () => {
const ImageInfoEffects = () => () => {
onFieldValueChange$('layout.useScene').subscribe((state) => {
if(state.initialValue != state.value) {
actions.setFieldValue('layout.position', null)
setFormStatus(
actions,
'layout.position',
'options',
actions,
'layout.position',
'options',
state.value == 1 ? WEB_OPTION : APP_OPTION
)
}
})
}
......@@ -86,7 +86,7 @@ const ImageInfo = () => {
label: (
<div>
{
isAdd || isEdit
isAdd || isEdit
? <span style={{color: '#ff4d4f'}}>* </span>
: null
}
......@@ -97,20 +97,20 @@ const ImageInfo = () => {
effects={ImageInfoEffects()}
>
{
isAdd || isEdit
isAdd || isEdit
? (
<FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit>
<Button onClick={handleCancel}>取消</Button>
</FormButtonGroup>
</FormButtonGroup>
)
: <></>
}
</SchemaForm>
</Card>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
<Prompt when={unsaved && (isAdd || isEdit)} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper>
)
}
export default ImageInfo
\ No newline at end of file
export default ImageInfo
......@@ -201,7 +201,14 @@ const schema = {
'superscript',
'subscript',
'hr',
]
],
media: {
// 如果要允许上传视频的话,需要重写uploadFn, https://www.yuque.com/braft-editor/be/gz44tn
accepts: {
video: false,
audio: false,
}
}
},
}
}
......@@ -211,4 +218,4 @@ const schema = {
}
}
export default schema;
\ No newline at end of file
export default schema;
......@@ -4,7 +4,7 @@
* @Description: 应付账款结算
*/
import React, { useRef, useEffect, useState } from 'react';
import React, { useRef, useEffect, useState, useMemo } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Card, Button, Modal, DatePicker, Tag, Space } from 'antd';
import NiceForm from '@/components/NiceForm';
......@@ -20,6 +20,8 @@ import { PublicApi } from '@/services/api'
import { Moment } from 'moment';
import { ColumnsType } from 'antd/es/table';
import EyePreview from '@/components/EyePreview';
import { priceFormat } from '@/utils/numberFomat'
import useIsExistsBrokerage from '../hooks/useIsExistsBrokerage';
interface SearchParams {
settlementName?: string,
......@@ -36,11 +38,11 @@ const { RangePicker } = DatePicker;
const formActions = createFormActions();
const PLATFORM_PAYER = 4;
const SettlementList = () => {
const [hasBrokerage, setHasBrokerage] = useState(true);
const ref = useRef<any>({})
const { hasBrokerage, filterColumns } = useIsExistsBrokerage();
const fetchListData = async (params) => {
// /settle/accounts/platform/settlement/pagePayableSettlement
const searchData = {
...params,
status: typeof params.status == 'undefined' ? 0 : params.status,
......@@ -65,9 +67,33 @@ const SettlementList = () => {
{title: '结算方式', dataIndex: 'settlementWayName'},
{title: '结算方', dataIndex: 'settlementName'},
{title: '总单数', dataIndex: 'totalCount'},
{title: '代收金额', dataIndex: 'collectAmount'},
{title: '佣金', dataIndex: 'brokerage'},
{title: '结算金额', dataIndex: 'amount'},
{
title: '代收金额',
dataIndex: 'collectAmount',
render: (text) => {
return (
<div>{`¥${priceFormat(text)}`}</div>
)
}
},
{
title: '佣金',
dataIndex: 'brokerage',
render: (text) => {
return (
<div>{`¥${priceFormat(text)}`}</div>
)
}
},
{
title: '结算金额',
dataIndex: 'amount',
render: (text) => {
return (
<div>{`¥${priceFormat(text)}`}</div>
)
}
},
{title: '结算时间', dataIndex: 'settlementTime'},
{title: '支付方式', dataIndex: 'payWayName'},
{
......@@ -105,16 +131,6 @@ const SettlementList = () => {
}
}
]
useEffect(() => {
PublicApi.getSettleAccountsPlatformSettlementIsExistsBrokerage()
.then(({data, code}) => {
if(code === 1000 && !data) {
setHasBrokerage(false)
}
})
}, [])
/**
*
* @param params 手动结算
......@@ -151,7 +167,7 @@ const SettlementList = () => {
const endTime = values.endTime ? values.endTime.format(format) + " 23:59:59" : "";
ref.current.reload({...values, startTime, endTime});
}
const frozenColumn = hasBrokerage ? columns : columns.filter((item: any) => item.dataIndex !== 'brokerage')
const frozenColumn = useMemo(() => filterColumns(columns, ["brokerage"]), [filterColumns, columns]);
return (
<PageHeaderWrapper>
<Card>
......
......@@ -4,7 +4,7 @@
* @Description: 积分结算详情页
*/
import React, { useRef, useState, useEffect } from 'react';
import React, { useRef, useState, useEffect, useMemo } from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { Card, PageHeader, Descriptions, Button} from 'antd';
import { history } from 'umi';
......@@ -18,10 +18,12 @@ import { detailSchema } from './schema'
import { usePageStatus } from '@/hooks/usePageStatus';
import StatusTag from '../components/StatusTag';
import { timeRange } from '@/utils/index';
import { priceFormat } from '@/utils/numberFomat'
import moment from 'moment';
import { PublicApi } from '@/services/api';
import add from '@/asserts/add.png';
import subtraction from '@/asserts/subtraction.png';
import useIsExistsBrokerage from '../hooks/useIsExistsBrokerage';
const formActions = createFormActions();
const inintColumns = [
......@@ -43,7 +45,11 @@ const inintColumns = [
render: (text) => {
return (
<div style={{display: "flex", flexDirection: "row", alignItems: 'center'}}>
<img src={text > 0 ? add : subtraction} width={16} height={16} />
{
(text > 0 || text < 0) && (
<img src={text > 0 ? add : subtraction} width={16} height={16} />
)
}
<span style={{marginLeft: '8px'}}>{text}</span>
</div>
)
......@@ -63,7 +69,11 @@ const inintColumns = [
render: (text) => {
return (
<div style={{display: "flex", flexDirection: "row", alignItems: 'center'}}>
<img src={text > 0 ? add : subtraction} width={16} height={16} />
{
(text > 0 || text < 0) && (
<img src={text > 0 ? add : subtraction} width={16} height={16} />
)
}
<span style={{marginLeft: '8px'}}>{text}</span>
</div>
)
......@@ -75,8 +85,12 @@ const inintColumns = [
render: (text) => {
return (
<div style={{display: "flex", flexDirection: "row", alignItems: 'center'}}>
<img src={text > 0 ? add : subtraction} width={16} height={16} />
<span style={{marginLeft: '8px'}}>{text}</span>
{
(text > 0 || text < 0) && (
<img src={text > 0 ? add : subtraction} width={16} height={16} />
)
}
<span style={{marginLeft: '8px'}}>{priceFormat(text)}</span>
</div>
)
}
......@@ -85,9 +99,9 @@ const inintColumns = [
// 如果佣金设置有效则显示这两列
const blackList = ["brokerage", "ratio"];
const logisticsDetail: React.FC = () => {
const { filterColumns } = useIsExistsBrokerage();
const ref = useRef<any>({});
const { id } = usePageStatus();
const [columns, setColumns] = useState(inintColumns);
const [infoDetail, setInfoDetail] = useState<any>();
const fetchListData = async (params) => {
const postData = {
......@@ -128,16 +142,7 @@ const logisticsDetail: React.FC = () => {
ref.current.reload({...rest, payStartTime, payEndTime, orderStartTime, orderEndTime});
}
useEffect(() => {
PublicApi.getSettleAccountsPlatformSettlementIsExistsBrokerage()
.then(({data, code}) => {
if(code === 1000 && !data) {
setColumns(inintColumns.filter((item) => blackList.includes(item.dataIndex)))
}
})
}, [])
const frozenColumn = useMemo(() => filterColumns(inintColumns, blackList), [filterColumns, inintColumns]);
return (
<PageHeaderWrapper
title={
......@@ -180,7 +185,7 @@ const logisticsDetail: React.FC = () => {
tableProps={{
rowKey: record => (record.orderNo + "-" + record.payTime),
}}
columns={columns}
columns={frozenColumn}
currentRef={ref}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
......
......@@ -68,7 +68,7 @@ export const schema: ISchema = {
{ label: '结算状态(所有)', value: 0 },
{ label: '待对账', value: 1 },
{ label: '待付款', value: 2 },
{ label: '收款', value: 3 },
{ label: '收款', value: 3 },
{ label: '已完成', value: 4 },
],
default: 0,
......
import React, { useState, useEffect, useCallback } from 'react';
import { PublicApi } from '@/services/api';
/**
* 是否拥有扣减佣金列,
*/
function useIsExistsBrokerage() {
const [hasBrokerage, setHasBrokerage] = useState(false);
useEffect(() => {
async function fetchBrokerageStatus() {
const { data, code } = await PublicApi.getSettleAccountsPlatformSettlementIsExistsBrokerage();
if (code === 1000) {
setHasBrokerage(data)
}
}
fetchBrokerageStatus();
}, [])
/**
* 过滤掉佣金比率,扣减佣金
*/
const filterColumns = useCallback((columns, blackList) => {
return hasBrokerage ? columns : columns.filter((_row) => !blackList.includes(_row.dataIndex));
}, [hasBrokerage])
return { hasBrokerage, filterColumns }
}
export default useIsExistsBrokerage;
......@@ -69,7 +69,7 @@ export const schema: ISchema = {
{ label: '结算状态(所有)', value: 0 },
{ label: '待对账', value: 1 },
{ label: '待付款', value: 2 },
{ label: '收款', value: 3 },
{ label: '收款', value: 3 },
{ label: '已完成', value: 4 },
],
default: 0,
......
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