Selaa lähdekoodia

feat: 公共锁库增加旧锁接收功能

lanjianrong 5 vuotta sitten
vanhempi
commit
b37da54e0b

+ 1 - 1
src/pages/Customer/Company/components/ConnectCompany/index.jsx

@@ -3,7 +3,7 @@ import React, { useState, useEffect, useRef } from 'react'
 import styles from './index.less'
 import { SearchOutlined, CloseOutlined } from '@ant-design/icons'
 import { useDebounceFn } from 'ahooks'
-import { useDispatch } from 'dva'
+import { useDispatch } from 'umi'
 import AddCompany from '@/pages/Customer/Company/components/AddCompany'
 import { createCustomer, queryCustomers } from '@/services/customer'
 import consts from '@/basic/consts'

+ 2 - 1
src/pages/Customer/Company/components/ConnectCompany/index.less

@@ -9,7 +9,8 @@
     .closeIcon {
       position: absolute;
       top: 5px;
-      right: 7px;
+      right: 8px;
+      font-size: 16px;
     }
   }
   .modalContent {

+ 91 - 0
src/pages/Product/Lock/Lockstore/components/ReceiveLock.jsx

@@ -0,0 +1,91 @@
+import { Button, message, Tag } from 'antd'
+import { useDispatch } from 'umi'
+import React, { useRef } from 'react'
+import styles from '@/pages/Customer/Company/components/ConnectCompany/index.less'
+import { CloseOutlined } from '@ant-design/icons'
+import consts from '@/basic/consts'
+import { apiReceiveOldLock, queryOldLockList } from '@/services/lock'
+import ProTable from '@ant-design/pro-table'
+
+const ReceiveLock = () => {
+  const dispatch = useDispatch()
+  const tRef = useRef(null)
+  const closeModal = () => {
+    dispatch({
+      type: 'single/changeModal'
+    })
+  }
+
+  const receiveLongle = async (name, id) => {
+    const { code = -1 } = await apiReceiveOldLock({ id })
+    if (code === consts.RET_CODE.SUCCESS) {
+      message.success(`锁(${name})接收成功`)
+      tRef.current?.reload()
+    }
+  }
+
+  const columns = [
+    {
+      dataIndex: 'keyNum',
+      title: '锁号'
+    },
+    {
+      dataIndex: 'category',
+      title: '办事处'
+    },
+    {
+      dataIndex: 'product',
+      title: '产品',
+      width: '60%',
+      render: text => (
+        <div className="flex">
+          {text.split('+').map(item => (
+            <Tag key={item} color="#886ab5" className="mr-1">
+              {item}
+            </Tag>
+          ))}
+        </div>
+      )
+    },
+    {
+      dataIndex: 'opreate',
+      title: '操作',
+      render: (_, record) => (
+        <Button size="small" onClick={() => receiveLongle(record.keyNum, record.id)}>
+          接收
+        </Button>
+      )
+    }
+  ]
+
+  return (
+    <div className={['ant-modal-content', styles.modalContainer].join(' ')}>
+      <div className={styles.modalHeader}>
+        <p>以下锁为系统升级前未接收的锁,请及时接收;新系统生成的锁,将在列表中按“本部门”展示。</p>
+        <span className={styles.closeIcon}>
+          <CloseOutlined onClick={closeModal} />
+        </span>
+      </div>
+      <div className={styles.modalContent}>
+        <ProTable
+          columns={columns}
+          actionRef={tRef}
+          toolBarRender={false}
+          search={false}
+          bordered={true}
+          request={async params => {
+            const { data: { longle, total } = { longle: [], total: 0 }, code = -1 } =
+              await queryOldLockList(params)
+            return {
+              data: longle,
+              success: code === consts.RET_CODE.SUCCESS,
+              total
+            }
+          }}
+        />
+      </div>
+    </div>
+  )
+}
+
+export default ReceiveLock

+ 45 - 23
src/pages/Product/Lock/Lockstore/index.jsx

@@ -1,5 +1,5 @@
-import React, { useState, useEffect } from 'react'
-import { Tag, Select, Tooltip, Input, DatePicker } from 'antd'
+import React, { useState } from 'react'
+import { Tag, Select, Tooltip, Input, DatePicker, Button } from 'antd'
 import ProTable from '@ant-design/pro-table'
 import consts from '@/consts'
 import { useModel } from 'umi'
@@ -11,6 +11,7 @@ import { useModal } from '@/components/Modal'
 import { useTableScroll } from '@/hooks/useAutoTable'
 import CompanyDetail from '@/pages/Customer/Company/components/CompanyDetail'
 import { refactorSortField } from '@/utils/utils'
+import ReceiveLock from './components/ReceiveLock'
 
 // 渲染产品标签
 export const ProductLabel = ({ data }) => {
@@ -62,25 +63,32 @@ const longleStatusNum = {
 
 const LockStore = () => {
   const [selectKeys] = useState([])
-  const { toggleDrawer, setDrawerProps } = useModal()
+  const { toggleDrawer, setDrawerProps, toggleModal, setModalProps } = useModal()
+  const showReceiveLockModal = () => {
+    setModalProps({
+      width: '60vw',
+      modalRender: () => <ReceiveLock />,
+      onCancel: () => toggleModal()
+    })
+    toggleModal()
+  }
   const { initialState: { permData } = { permData: {} } } = useModel('@@initialState')
   const [state, setState] = useState({
     params: { dataPermission: 'oneself' },
     data: [],
     prodList: [], // 产品列表
+    totalOld: 0, // 待接收锁总数
     id: ''
   })
 
-  useEffect(() => {
-    // 获取软件锁产品列表
-    async function fetchSoftProducts() {
-      const { code = -1, data = [] } = await querySoftwareProducts()
-      if (code === consts.RET_CODE.SUCCESS) {
-        setState({ ...state, prodList: data })
-      }
+  // 获取软件锁产品列表
+  async function fetchSoftProducts() {
+    const { code = -1, data = [] } = await querySoftwareProducts()
+    if (code === consts.RET_CODE.SUCCESS) {
+      setState({ ...state, prodList: data })
     }
-    fetchSoftProducts()
-  }, [])
+  }
+
   const handleSearch = value => {
     setState({ ...state, params: { ...state.params, search: value } })
   }
@@ -225,19 +233,25 @@ const LockStore = () => {
     }
   ]
   const { getScrollRef, redoHeight } = useTableScroll(columns, selectKeys)
+
   return (
     <ProTable
       rowKey={record => record.id}
       search={false}
       headerTitle={
-        <Select
-          defaultValue="oneself"
-          dropdownMatchSelectWidth={false}
-          onChange={e => {
-            setState({ ...state, params: { ...state.params, dataPermission: e } })
-          }}
-          options={permData?.product || []}
-        />
+        <>
+          <Select
+            defaultValue="oneself"
+            dropdownMatchSelectWidth={false}
+            onChange={e => {
+              setState({ ...state, params: { ...state.params, dataPermission: e } })
+            }}
+            options={permData?.product || []}
+          />
+          <Button type="primary" className="ml-4" onClick={() => showReceiveLockModal()}>
+            待接收锁 ({state.totalOld})
+          </Button>
+        </>
       }
       bordered
       params={state.params}
@@ -247,8 +261,11 @@ const LockStore = () => {
       }}
       request={async (params, sort, filter) => {
         const srotOrder = refactorSortField(sort)
-        const { code = -1, data: { longle = [], total = 0 } = { longle: [], total: 0 } } =
-          await queryLock({ ...params, ...srotOrder, ...filter })
+        const {
+          code = -1,
+          data: { longle = [], total = 0, totalOld = 0 } = { longle: [], total: 0, totalOld: 0 }
+        } = await queryLock({ ...params, ...srotOrder, ...filter })
+        setState({ ...state, totalOld })
         return {
           data: longle,
           success: code === consts.RET_CODE.SUCCESS,
@@ -288,8 +305,13 @@ const LockStore = () => {
             labelInValue={true}
             allowClear={true}
             placeholder="请选择产品"
+            onDropdownVisibleChange={async e => {
+              e && !state.prodList?.length && (await fetchSoftProducts())
+            }}
             options={state.prodList.map(item => ({ value: item.title }))}
-            onChange={e => setState({ ...state, params: { ...state.params, product: e } })}
+            onChange={e =>
+              setState({ ...state, params: { ...state.params, product: e?.value || '' } })
+            }
           />
         ]
       }}

+ 14 - 0
src/services/lock.js

@@ -28,3 +28,17 @@ export async function apiSoftwareAddLonglelog(payload) {
 export async function querySoftwareProducts(params) {
   return request.get('/software/product', { params })
 }
+
+/** 获取旧锁列表 */
+export async function queryOldLockList(params) {
+  return request.get('/software/receiveListOld', {
+    params
+  })
+}
+
+/** 接收旧锁 */
+export async function apiReceiveOldLock(params) {
+  return request.post('/software/receiveOld', {
+    data: params
+  })
+}