Просмотр исходного кода

关联资源,不能关联自己

shaogen1995 2 месяцев назад
Родитель
Сommit
76745e1cae

+ 4 - 1
src/pages/Zother/AddGood/index.tsx

@@ -26,9 +26,11 @@ type Props = {
   formZi: baseFormType[]
   formDefId: number
   kuList: any[]
+  // 关联资源,不能选择自己
+  ziYuanNow?: any
 }
 
-function AddGood({ formDefId, sId, closeFu, succFu, formZi, kuList }: Props) {
+function AddGood({ formDefId, sId, closeFu, succFu, formZi, kuList, ziYuanNow }: Props) {
   // 级联选择
   const jiLianKey = useMemo(() => {
     return formZi.filter(v => ['关联标签', '关联字典'].includes(v.tag)).map(c => c.fieldName)
@@ -328,6 +330,7 @@ function AddGood({ formDefId, sId, closeFu, succFu, formZi, kuList }: Props) {
           formDefId={ziYuanId}
           kuList={kuList}
           formZi={formZi}
+          ziYuanNow={ziYuanNow}
         />
       ) : null}
     </Modal>

+ 6 - 2
src/pages/Zother/SelectGoods/index.tsx

@@ -23,6 +23,8 @@ type Props = {
   formZi: baseFormType[]
   isOne?: boolean // 单选
   canObj?: any //其他额外的参数
+  // 关联资源,不能选择自己
+  ziYuanNow?: any
 }
 
 function SelectGoods({
@@ -34,7 +36,8 @@ function SelectGoods({
   kuList,
   formZi,
   isOne,
-  canObj
+  canObj,
+  ziYuanNow
 }: Props) {
   const [formData, setFormData] = useState({ ...selectTopBase, formDefId })
   const formDataRef = useRef({ ...selectTopBase, formDefId })
@@ -147,6 +150,7 @@ function SelectGoods({
         render: (item: GoodsType) => (
           <div className='tableAuto'>
             <Checkbox
+              disabled={ziYuanNow && ziYuanNow.fId === formDefId && ziYuanNow.id === item.id}
               checked={checkArr.map(v => v.id).includes(item.id)}
               onChange={() => checkFu(item)}
             ></Checkbox>
@@ -154,7 +158,7 @@ function SelectGoods({
         )
       }
     ]
-  }, [checkArr, checkFu, isOne])
+  }, [checkArr, checkFu, formDefId, isOne, ziYuanNow])
 
   // 点击提交
   const btnOk = useCallback(() => {

+ 1 - 0
src/pages/Zother/ZgoodsInfo/index.tsx

@@ -246,6 +246,7 @@ function ZgoodsInfo() {
           succFu={(val, obj) => getInfoFu()}
           formZi={formZi}
           formDefId={fId}
+          ziYuanNow={{ fId: Number(fId), id: Number(id) }}
         />
       ) : null}
     </div>