|
|
@@ -11,14 +11,12 @@ import TextArea from 'antd/es/input/TextArea'
|
|
|
import ZRichTexts from '@/components/ZRichTexts'
|
|
|
|
|
|
type Props = {
|
|
|
- acShuTxt: string
|
|
|
addInfo: A1AddInfoType
|
|
|
addFu: () => void
|
|
|
closeFu: () => void
|
|
|
- isNoAcIds: string[] //没有数据或者删除了的时候-既右侧没有操作的时候用到
|
|
|
}
|
|
|
|
|
|
-function A1add({ addInfo, addFu, closeFu, isNoAcIds, acShuTxt }: Props) {
|
|
|
+function A1add({ addInfo, addFu, closeFu }: Props) {
|
|
|
// 富文本的ref
|
|
|
const ZRichTextRef = useRef<any>(null)
|
|
|
|
|
|
@@ -28,11 +26,11 @@ function A1add({ addInfo, addFu, closeFu, isNoAcIds, acShuTxt }: Props) {
|
|
|
const [acCardInfo, setAcCardInfo] = useState({} as TypeA1dict)
|
|
|
const [parentIdArr, setParentIdArr] = useState<string[] | null>(null)
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- console.log(acCardInfo, parentIdArr)
|
|
|
- }, [acCardInfo, parentIdArr])
|
|
|
+ // useEffect(() => {
|
|
|
+ // console.log(acCardInfo, parentIdArr)
|
|
|
+ // }, [acCardInfo, parentIdArr])
|
|
|
|
|
|
- const saveIdsRef = useRef<string[]>([])
|
|
|
+ // const saveIdsRef = useRef<string[]>([])
|
|
|
|
|
|
useEffect(() => {
|
|
|
// console.log('xxxxxxxxxx', addInfo)
|
|
|
@@ -48,13 +46,11 @@ function A1add({ addInfo, addFu, closeFu, isNoAcIds, acShuTxt }: Props) {
|
|
|
}
|
|
|
|
|
|
if (idsRes) {
|
|
|
- // 保存的时候需要补前面3个级别
|
|
|
- saveIdsRef.current = idsRes.filter((v, i) => i <= 2)
|
|
|
- // 去掉0和前2级
|
|
|
- idsRes = idsRes.filter((v, i) => i > 2)
|
|
|
+ // 去掉前面的0
|
|
|
+ idsRes = idsRes.filter((v, i) => !(i === 0 && v === '0'))
|
|
|
}
|
|
|
|
|
|
- setParentIdArr(idsRes)
|
|
|
+ setParentIdArr(idsRes ? idsRes.map(v => v + '') : [])
|
|
|
}, [addInfo])
|
|
|
|
|
|
const cardChange = useCallback((aa: any, bb: any) => {
|
|
|
@@ -109,37 +105,19 @@ function A1add({ addInfo, addFu, closeFu, isNoAcIds, acShuTxt }: Props) {
|
|
|
|
|
|
if (acCardInfo) parentId = addInfo.txt === '编辑' ? acCardInfo.parentId : acCardInfo.id
|
|
|
if (parentIdArr && parentId) {
|
|
|
- let arrTemp = [...saveIdsRef.current, ...parentIdArr.filter(v => v !== addInfo.id)]
|
|
|
+ let arrTemp = [...parentIdArr.filter(v => v !== addInfo.id)]
|
|
|
ancestor = arrTemp.join(',')
|
|
|
}
|
|
|
|
|
|
- // 新增并且没有父级
|
|
|
- if (addInfo.txt === '新增' && !parentId && !ancestor) {
|
|
|
- // console.log('xxx', saveIdsRef.current)
|
|
|
-
|
|
|
- parentId = saveIdsRef.current[saveIdsRef.current.length - 1]
|
|
|
- ancestor = saveIdsRef.current.join(',')
|
|
|
- // console.log(123, parentId, ancestor)
|
|
|
-
|
|
|
- // 外层没有选中
|
|
|
- if (!addInfo.acInfo.id) {
|
|
|
- parentId = isNoAcIds[isNoAcIds.length - 1]
|
|
|
- ancestor = isNoAcIds.join(',')
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // let level = 1
|
|
|
- // if (parentIdArr) {
|
|
|
- // level = addInfo.txt === '新增' ? acCardInfo.level + 1 : acCardInfo.level
|
|
|
- // }
|
|
|
const obj = {
|
|
|
...values,
|
|
|
id: addInfo.txt === '编辑' ? addInfo.id : null,
|
|
|
- ancestor,
|
|
|
+ ancestor: '0,' + ancestor,
|
|
|
// level,
|
|
|
parentId,
|
|
|
type: 'dict',
|
|
|
- rtf: JSON.stringify(rtf.val || '')
|
|
|
+ rtf: JSON.stringify(rtf.val || ''),
|
|
|
+ sort: 999
|
|
|
}
|
|
|
// console.log(123, obj)
|
|
|
// if (1 + 1 === 2) {
|
|
|
@@ -154,7 +132,7 @@ function A1add({ addInfo, addFu, closeFu, isNoAcIds, acShuTxt }: Props) {
|
|
|
closeFu()
|
|
|
}
|
|
|
},
|
|
|
- [acCardInfo, addFu, addInfo.acInfo.id, addInfo.id, addInfo.txt, closeFu, isNoAcIds, parentIdArr]
|
|
|
+ [acCardInfo, addFu, addInfo.id, addInfo.txt, closeFu, parentIdArr]
|
|
|
)
|
|
|
|
|
|
const [typeSon, settypeSon] = useState('2')
|
|
|
@@ -189,8 +167,7 @@ function A1add({ addInfo, addFu, closeFu, isNoAcIds, acShuTxt }: Props) {
|
|
|
changeOnSelect
|
|
|
fieldNames={{ label: 'name', value: 'id', children: 'children' }}
|
|
|
options={treeData}
|
|
|
- // placeholder={addInfo.txt === '编辑' ? '空' : '请选择'}
|
|
|
- placeholder={acShuTxt}
|
|
|
+ placeholder={acCardInfo.name === '程哲碑' ? '(空)' : '请选择父级节点'}
|
|
|
value={parentIdArr ? [...parentIdArr] : []}
|
|
|
onChange={cardChange}
|
|
|
/>
|
|
|
@@ -203,7 +180,12 @@ function A1add({ addInfo, addFu, closeFu, isNoAcIds, acShuTxt }: Props) {
|
|
|
rules={[{ required: true, message: '请输入节点名称!' }]}
|
|
|
getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
|
|
|
>
|
|
|
- <Input maxLength={30} showCount placeholder='请输入内容' />
|
|
|
+ <Input
|
|
|
+ disabled={acCardInfo.preset === '1'}
|
|
|
+ maxLength={30}
|
|
|
+ showCount
|
|
|
+ placeholder='请输入内容'
|
|
|
+ />
|
|
|
</Form.Item>
|
|
|
|
|
|
<div className='fromRow2'>
|
|
|
@@ -252,6 +234,7 @@ function A1add({ addInfo, addFu, closeFu, isNoAcIds, acShuTxt }: Props) {
|
|
|
<Form.Item
|
|
|
label='跳转链接'
|
|
|
name='thumb'
|
|
|
+ rules={[{ required: true, message: '请输入跳转链接!' }]}
|
|
|
getValueFromEvent={e => e.target.value.replace(/\s+/g, '')}
|
|
|
>
|
|
|
<TextArea maxLength={100} showCount placeholder='请输入内容' />
|