Ver código fonte

feat: 软件锁备注的编辑和删除

outaozhen 4 anos atrás
pai
commit
c31fb4645d

+ 15 - 9
src/pages/Product/Lock/LockStore/components/LockDetail/OpreateLock.jsx

@@ -7,7 +7,7 @@ import consts from '@/basic/consts'
 import { useDebounceFn } from 'ahooks'
 import { apiSoftwareAddLonglelog, apiReceiveLock } from '@/services/product'
 import { useDispatch, connect } from 'umi'
-import { ProFormTextArea } from '@ant-design/pro-form'
+import { ProFormText, ProFormTextArea } from '@ant-design/pro-form'
 import styles from '@/pages/Customer/Company/components/ConnectCompany/index.less'
 
 export const lockTypeEnum = {
@@ -35,14 +35,13 @@ const OpreateLock = props => {
     onCancel,
     type,
     longleId,
-    isOperation,
-    id,
-    mark,
+    defaultValues,
     keyNum,
     prodList,
     upgradeProduct,
     ...resetModalProps
   } = props
+  console.log(defaultValues)
   const [form] = Form.useForm()
   const dispatch = useDispatch()
   const scrollRef = useRef()
@@ -146,9 +145,11 @@ const OpreateLock = props => {
       if (type === lockTypeEnum.RECOVER) {
         form.setFieldsValue({ longleId })
       }
-      // if (type === lockTypeEnum.REMARK) {
-      //   form.setFieldsValue({ id, mark })
-      // }
+      if (defaultValues) {
+        if (type === lockTypeEnum.REMARK) {
+          form?.setFieldsValue({ mark: defaultValues.mark })
+        }
+      }
     }
   }, [resetModalProps.visible, type])
 
@@ -171,7 +172,7 @@ const OpreateLock = props => {
             })
           }
         }
-        if (isOperation === true) {
+        if (defaultValues) {
           const { code = -1 } = await apiUpdateLonglelog({ id })
           if (code === consts.RET_CODE.SUCCESS) {
             // form.current?.setFieldsValue({
@@ -383,7 +384,12 @@ const OpreateLock = props => {
           </Form.Item>
         ) : null}
 
-        {type === lockTypeEnum.REMARK ? <ProFormTextArea name="mark" label="备注" /> : null}
+        {type === lockTypeEnum.REMARK ? (
+          <>
+            <ProFormText name="id" hidden />
+            <ProFormTextArea name="mark" label="备注" />
+          </>
+        ) : null}
 
         {type === lockTypeEnum.RECOVER || type === lockTypeEnum.RECEIVE ? (
           <>

+ 3 - 7
src/pages/Product/Lock/LockStore/components/LockDetail/TabList.tsx

@@ -130,12 +130,10 @@ const LockTabList: React.FC<LockTabListProps> = ({
     }
   }
 
-  const openLockModal = (type, isOperation, id, mark) => {
+  const openLockModal = (type, defaultValues) => {
     dispatchModal('M_OPREATE_LOCK', {
       type,
-      isOperation,
-      id,
-      mark,
+      defaultValues,
       onConfirm: handleAddLonglelog,
       keyNum,
       upgradeProduct,
@@ -192,9 +190,7 @@ const LockTabList: React.FC<LockTabListProps> = ({
                       type="primary"
                       ghost
                       size="small"
-                      onClick={() =>
-                        openLockModal(lockTypeEnum.REMARK, item.isOperation, item.id, item.mark)
-                      }>
+                      onClick={() => openLockModal(lockTypeEnum.REMARK, item)}>
                       编辑
                     </Button>
                   </span>