outaozhen il y a 5 ans
Parent
commit
e8de8e92b2

+ 63 - 36
src/pages/Product/Lock/Lockstore/components/LocksDetail/LockModal.jsx

@@ -5,7 +5,7 @@ import { SearchOutlined, CloseOutlined } from '@ant-design/icons'
 import { queryContact } from '@/services/contact'
 import { queryLock } from '@/services/lock'
 import consts from '@/basic/consts'
-import { useDebounceFn, useThrottleFn } from 'ahooks'
+import { useDebounceFn } from 'ahooks'
 
 export const lockTypeEnum = {
   SALE: 3,
@@ -34,21 +34,38 @@ const LockModal = props => {
   const [state, setState] = useState({
     laoding: true,
     longle: [],
+    client: [],
     searchVal: '',
     page: 1,
     size: 10,
     total: 0
   })
   const initData = async params => {
-    const { data: { longle, total } = { longle: [], total: 0 }, code = -1 } = await queryLock(
-      params
-    )
-    if (code === consts.RET_CODE.SUCCESS) {
-      setState({ ...state, longle: state.longle.concat(longle), total, laoding: false })
+    if (type !== lockTypeEnum.UPDATE) {
+      const { data: { longle, total } = { longle: [], total: 0 }, code = -1 } = await queryLock(
+        params
+      )
+      if (code === consts.RET_CODE.SUCCESS) {
+        setState({ ...state, longle: state.longle.concat(longle), total, laoding: false })
+      }
+    }
+    if (type !== lockTypeEnum.SALE) {
+      const { data: { client, total } = { client: [], total: 0 }, code = -1 } = await queryContact(
+        params
+      )
+      if (code === consts.RET_CODE.SUCCESS) {
+        setState({ ...state, client: state.client.concat(client), total, laoding: false })
+      }
     }
   }
   useEffect(() => {
-    initData({ page: 1, size: 10 })
+    if (type !== lockTypeEnum.UPDATE) {
+      initData({ page: 1, size: 10 })
+    }
+    if (type !== lockTypeEnum.SALE) {
+      initData({ page: 1, size: 10 })
+    }
+    // initData({ page: 1, size: 10 })
   }, [])
   const onChange = e => {
     const { value = '' } = e.target || e.currentTarget
@@ -65,9 +82,11 @@ const LockModal = props => {
     }
   }, [visible, type])
 
-  const handleOk = values => {
-    values.status = type
-    onConfirm(values)
+  const handleonOk = () => {
+    form.validateFields().then(values => {
+      values.status = type
+      onConfirm(values)
+    })
   }
 
   return (
@@ -93,7 +112,39 @@ const LockModal = props => {
       //   })
       // }}
       width={800}
-      footer={null}>
+      footer={
+        type !== lockTypeEnum.UPDATE &&
+        type !== lockTypeEnum.RECOVER &&
+        type !== lockTypeEnum.REMARK ? null : (
+          <div className={['zh-text-right', styles.modalFooter].join(' ')}>
+            <Button className="zh-mg-right-10" onClick={onCancel}>
+              取消
+            </Button>
+            <Button key="submit" type="primary" loading={loading} onClick={handleonOk}>
+              确定
+            </Button>
+          </div>
+        )
+      }>
+      {type === lockTypeEnum.SALE ? (
+        <div className={[styles.modalContainer].join(' ')}>
+          <div className={styles.modalContent}>
+            <Spin spinning={state.laoding}>
+              {state.longle.map(item => (
+                <div key={item.id} className={styles.card}>
+                  <div className="zh-flex-sub">{item.clientName}</div>
+                  <div className="zh-flex-sub zh-justify-between">
+                    <span>{item.companyName}</span>
+                    <Button type="primary" size="small">
+                      选择ta
+                    </Button>
+                  </div>
+                </div>
+              ))}
+            </Spin>
+          </div>
+        </div>
+      ) : null}
       {type === lockTypeEnum.CHANGE ? (
         <div className={[styles.modalContainer].join(' ')}>
           <div className={styles.modalContent}>
@@ -104,7 +155,7 @@ const LockModal = props => {
                   <div className="zh-flex-sub zh-justify-between">
                     <span>{item.product}</span>
                     <Button type="primary" size="small">
-                      关联
+                      更换
                     </Button>
                   </div>
                 </div>
@@ -123,14 +174,6 @@ const LockModal = props => {
                 <Option key="广东算量新定额">广东算量新定额</Option>
               </Select>
             </Form.Item>
-            <div className={['zh-text-right', styles.modalFooter].join(' ')}>
-              <Button className="zh-mg-right-10" onClick={onCancel}>
-                取消
-              </Button>
-              <Button key="submit" type="primary" loading={loading} onClick={handleOk}>
-                确定
-              </Button>
-            </div>
           </>
         ) : null}
 
@@ -139,14 +182,6 @@ const LockModal = props => {
             <Form.Item name="mark" label="备注">
               <Input.TextArea />
             </Form.Item>
-            <div className={['zh-text-right', styles.modalFooter].join(' ')}>
-              <Button className="zh-mg-right-10" onClick={onCancel}>
-                取消
-              </Button>
-              <Button key="submit" type="primary" loading={loading} onClick={handleOk}>
-                确定
-              </Button>
-            </div>
           </>
         ) : null}
 
@@ -158,14 +193,6 @@ const LockModal = props => {
             <Form.Item name="longleId" hidden>
               <Input />
             </Form.Item>
-            <div className={['zh-text-right', styles.modalFooter].join(' ')}>
-              <Button className="zh-mg-right-10" onClick={onCancel}>
-                取消
-              </Button>
-              <Button key="submit" type="primary" loading={loading} onClick={handleOk}>
-                确定
-              </Button>
-            </div>
           </>
         ) : null}
       </Form>