|
|
@@ -25,6 +25,9 @@ function E2edit() {
|
|
|
const isEdit = useMemo(() => {
|
|
|
return ['2'].includes(key)
|
|
|
}, [key])
|
|
|
+ const isView = useMemo(() => {
|
|
|
+ return ['4'].includes(key)
|
|
|
+ }, [key])
|
|
|
|
|
|
// 保存附件
|
|
|
const getFileListByIdsFu = useCallback(async (ids: string[]) => {
|
|
|
@@ -43,7 +46,9 @@ function E2edit() {
|
|
|
// 设置数据和富文本和附件
|
|
|
setStoryInfo(res.data)
|
|
|
ZRichTextRef.current?.ritxtShowFu(res.data.rtf || '')
|
|
|
- getFileListByIdsFu(res.data.fileIds.split(',') || [])
|
|
|
+ if (res.data.fileIds) {
|
|
|
+ getFileListByIdsFu(res.data.fileIds.split(',') || [])
|
|
|
+ }
|
|
|
console.log(res.data)
|
|
|
}
|
|
|
},
|
|
|
@@ -76,15 +81,15 @@ function E2edit() {
|
|
|
|
|
|
// 初始获取详情
|
|
|
useEffect(() => {
|
|
|
- if (isEdit) {
|
|
|
+ if (isEdit || isView) {
|
|
|
getInfoFu(id)
|
|
|
}
|
|
|
- }, [getInfoFu, id, isEdit, key])
|
|
|
+ }, [getInfoFu, id, isEdit, key, isView])
|
|
|
|
|
|
// table点击各种操作按钮
|
|
|
- const tableBtnFu = useCallback((id: number, key: string) => {
|
|
|
- history.push(`/story_edit/${key}/${id}`)
|
|
|
- }, [])
|
|
|
+ // const tableBtnFu = useCallback((id: number, key: string) => {
|
|
|
+ // history.push(`/story_edit/${key}/${id}`)
|
|
|
+ // }, [])
|
|
|
|
|
|
// 提交
|
|
|
const submitFu = useCallback(() => {
|
|
|
@@ -100,25 +105,27 @@ function E2edit() {
|
|
|
<Button size='small' type='text' onClick={() => console.log('查看藏品')}>
|
|
|
查看
|
|
|
</Button>
|
|
|
- <MyPopconfirm
|
|
|
- txtK='删除'
|
|
|
- onConfirm={() =>
|
|
|
- setStoryInfo({
|
|
|
- ...storyInfo,
|
|
|
- goods: storyInfo.goods.filter((v: any) => v.id !== item.id)
|
|
|
- })
|
|
|
- }
|
|
|
- />
|
|
|
+ {!isView && (
|
|
|
+ <MyPopconfirm
|
|
|
+ txtK='删除'
|
|
|
+ onConfirm={() =>
|
|
|
+ setStoryInfo({
|
|
|
+ ...storyInfo,
|
|
|
+ goods: storyInfo.goods.filter((v: any) => v.id !== item.id)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ />
|
|
|
+ )}
|
|
|
</>
|
|
|
)
|
|
|
}
|
|
|
]
|
|
|
- }, [storyInfo])
|
|
|
+ }, [isView, storyInfo])
|
|
|
return (
|
|
|
<div className={styles.D1edit} id='editBox'>
|
|
|
<div className='editMain'>
|
|
|
<div className={styles.EditTop}>
|
|
|
- <div className='pageTitle'>藏品故事-新增</div>
|
|
|
+ <div className='pageTitle'>藏品故事-{isEdit ? '编辑' : isView ? '查看' : '新增'}</div>
|
|
|
<div className='EdTit'>
|
|
|
<div>藏品故事</div>
|
|
|
</div>
|
|
|
@@ -130,7 +137,7 @@ function E2edit() {
|
|
|
</div>
|
|
|
<div className='Edtop1rr'>
|
|
|
<Input
|
|
|
- readOnly={false}
|
|
|
+ readOnly={isView}
|
|
|
placeholder='请输入内容,不超过30个字'
|
|
|
value={storyInfo.name || ''}
|
|
|
onChange={e => setStoryInfo({ ...storyInfo, name: e.target.value })}
|
|
|
@@ -142,7 +149,7 @@ function E2edit() {
|
|
|
<div className='Edtop1row Edtop1rowFull'>
|
|
|
<div className='Edtop1ll'>关联产品 :</div>
|
|
|
<div className='Edtop1rr'>
|
|
|
- <Button type='primary' onClick={() => setShowSelectGoods(true)}>
|
|
|
+ <Button disabled={isView} type='primary' onClick={() => setShowSelectGoods(true)}>
|
|
|
添加藏品
|
|
|
</Button>
|
|
|
<MyTable
|
|
|
@@ -175,7 +182,7 @@ function E2edit() {
|
|
|
dirCode='guShiText'
|
|
|
check={false}
|
|
|
myUrl='cms/story/upload'
|
|
|
- isLook={false}
|
|
|
+ isLook={isView}
|
|
|
ref={ZRichTextRef}
|
|
|
/>
|
|
|
</div>
|
|
|
@@ -184,7 +191,7 @@ function E2edit() {
|
|
|
<div className='Edtop1ll'>备注 :</div>
|
|
|
<div className='Edtop1rr'>
|
|
|
<TextArea
|
|
|
- readOnly={false}
|
|
|
+ readOnly={isView}
|
|
|
placeholder='请输入内容,不超过500个字'
|
|
|
value={storyInfo.remark || ''}
|
|
|
onChange={e => setStoryInfo({ ...storyInfo, remark: e.target.value })}
|
|
|
@@ -197,6 +204,7 @@ function E2edit() {
|
|
|
<div className='Edtop1ll'>上传附件 :</div>
|
|
|
<div className='Edtop1rr'>
|
|
|
<Z3upFilesRef
|
|
|
+ isLook={isView}
|
|
|
moduleId={id !== 'null' ? Number(id) : 0}
|
|
|
ref={fileRef}
|
|
|
dirCode='guShiTextFile'
|
|
|
@@ -209,12 +217,20 @@ function E2edit() {
|
|
|
|
|
|
{/* 操作按钮 */}
|
|
|
<div className={styles.EditBtn}>
|
|
|
- <div>
|
|
|
- <Button type='primary' onClick={() => submitFu()}>
|
|
|
- 提交
|
|
|
- </Button>
|
|
|
- <MyPopconfirm txtK='取消' onConfirm={() => backPageFu('-1')} />
|
|
|
- </div>
|
|
|
+ {isView ? (
|
|
|
+ <div>
|
|
|
+ <Button type='default' onClick={() => backPageFu('-1')}>
|
|
|
+ 返回
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ <div>
|
|
|
+ <Button type='primary' onClick={() => submitFu()}>
|
|
|
+ 提交
|
|
|
+ </Button>
|
|
|
+ <MyPopconfirm txtK='取消' onConfirm={() => backPageFu('-1')} />
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|