lanjianrong hace 5 años
padre
commit
8476706ae4

+ 9 - 14
src/pages/Product/Lock/Lockstore/components/LocksDetail/LockModal.jsx

@@ -32,7 +32,7 @@ const LockModal = props => {
     layout: 'vertical'
   }
   const [state, setState] = useState({
-    laoding: true,
+    laoding: false,
     longle: [],
     client: [],
     searchVal: '',
@@ -41,7 +41,8 @@ const LockModal = props => {
     total: 0
   })
   const initData = async params => {
-    if (type !== lockTypeEnum.UPDATE) {
+    setState({ ...state, loading: true })
+    if (type === lockTypeEnum.CHANGE) {
       const { data: { longle, total } = { longle: [], total: 0 }, code = -1 } = await queryLock(
         params
       )
@@ -54,7 +55,7 @@ const LockModal = props => {
         }
       }
     }
-    if (type !== lockTypeEnum.SALE) {
+    if (type === lockTypeEnum.SALE) {
       const { data: { client, total } = { client: [], total: 0 }, code = -1 } = await queryContact(
         params
       )
@@ -69,20 +70,13 @@ const LockModal = props => {
     }
   }
   useEffect(() => {
-    if (type !== lockTypeEnum.UPDATE) {
+    if (type === lockTypeEnum.CHANGE || type === lockTypeEnum.SALE) {
       initData({ page: 1, size: 10 })
     }
-    if (type !== lockTypeEnum.SALE) {
-      initData({ page: 1, size: 10 })
-    }
-    // initData({ page: 1, size: 10 })
   }, [type])
   const onChange = e => {
     const { value = '' } = e.target || e.currentTarget
-    if (type !== lockTypeEnum.UPDATE) {
-      initData({ search: value, page: state.page, size: state.size })
-    }
-    if (type !== lockTypeEnum.SALE) {
+    if (type === lockTypeEnum.CHANGE || type === lockTypeEnum.SALE) {
       initData({ search: value, page: state.page, size: state.size })
     }
   }
@@ -90,6 +84,7 @@ const LockModal = props => {
   const { run: handleInputChange } = useDebounceFn(onChange)
   useEffect(() => {
     if (visible) {
+      setState({ ...state, searchVal: '' })
       form.resetFields()
       if (type === lockTypeEnum.RECOVER) {
         form.setFieldsValue({ longleId, status })
@@ -145,8 +140,8 @@ const LockModal = props => {
         <div className={[styles.modalContainer].join(' ')}>
           <div className={styles.modalContent}>
             <Spin spinning={state.laoding}>
-              {state.client.map((item, index) => (
-                <div key={index} className={styles.card}>
+              {state.client.map(item => (
+                <div key={item.id} className={styles.card}>
                   <div className="zh-flex-sub">{item.clientName}</div>
                   <div className="zh-flex-sub">{item.position}</div>
                   <div className="zh-flex-sub">{item.telephone}</div>