Przeglądaj źródła

feat: 公共锁库功能完善

lanjianrong 5 lat temu
rodzic
commit
e18e433a7d

+ 80 - 28
src/pages/Product/Lock/Lockstore/index.jsx

@@ -1,15 +1,16 @@
-import React, { useState } from 'react'
-import { Tag, Select, Tooltip, Input } from 'antd'
+import React, { useState, useEffect } from 'react'
+import { Tag, Select, Tooltip, Input, DatePicker } from 'antd'
 import ProTable from '@ant-design/pro-table'
 import consts from '@/consts'
 import { useModel } from 'umi'
-import { queryLock } from '@/services/lock'
+import { queryLock, querySoftwareProducts } from '@/services/lock'
 import LocksDetail from '@/pages/Product/Lock/LockStore/components/LocksDetail'
 import ContactDetail from '@/pages/Customer/Client/components/ClientDetail'
 import SoftwareDetail from '@/pages/Product/Lock/LockStore/components/SoftwareDetail'
 import { useModal } from '@/components/Modal'
 import { useTableScroll } from '@/hooks/useAutoTable'
 import CompanyDetail from '@/pages/Customer/Company/components/CompanyDetail'
+import { refactorSortField } from '@/utils/utils'
 
 // 渲染产品标签
 export const ProductLabel = ({ data }) => {
@@ -30,15 +31,33 @@ export const ProductLabel = ({ data }) => {
 }
 
 const longleStatusNum = {
-  1: '生成',
-  2: '接收',
-  3: '借出',
-  4: '销售',
-  5: '升级',
-  6: '更换',
-  7: '收回',
-  8: '备注',
-  9: '赠送'
+  1: {
+    text: '生成'
+  },
+  2: {
+    text: '接收'
+  },
+  3: {
+    text: '借出'
+  },
+  4: {
+    text: '销售'
+  },
+  5: {
+    text: '升级'
+  },
+  6: {
+    text: '更换'
+  },
+  7: {
+    text: '收回'
+  },
+  8: {
+    text: '备注'
+  },
+  9: {
+    text: '赠送'
+  }
 }
 
 const LockStore = () => {
@@ -48,8 +67,20 @@ const LockStore = () => {
   const [state, setState] = useState({
     params: { dataPermission: 'oneself' },
     data: [],
+    prodList: [], // 产品列表
     id: ''
   })
+
+  useEffect(() => {
+    // 获取软件锁产品列表
+    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 } })
   }
@@ -111,7 +142,6 @@ const LockStore = () => {
     {
       title: '锁号',
       dataIndex: 'keyNum',
-      key: 'keyNum',
       width: 150,
       render: (keyNum, record) => (
         <span
@@ -124,7 +154,6 @@ const LockStore = () => {
     {
       title: '产品',
       dataIndex: 'product',
-      key: 'product',
       width: 200,
       render: text => {
         return <ProductLabel data={text} />
@@ -133,20 +162,25 @@ const LockStore = () => {
     {
       title: '出库时间',
       dataIndex: 'makeDay',
-      key: 'makeDay',
+      valueType: 'date',
+      sorter: true,
       width: 150
     },
     {
       title: '状态',
       dataIndex: 'status',
-      key: 'status',
       width: 150,
-      render: status => <>{longleStatusNum[status]}</>
+      filters: true,
+      onFilter: true,
+      valueType: 'select',
+      valueEnum: longleStatusNum,
+      render: (_, { status }) => {
+        return <>{longleStatusNum[status]?.text}</>
+      }
     },
     {
       title: '责任人',
       dataIndex: 'responsible',
-      key: 'responsible',
       width: 150,
       render: (text, record) => (
         <span
@@ -170,7 +204,6 @@ const LockStore = () => {
     {
       title: '联系人',
       dataIndex: 'client',
-      key: 'client',
       width: 150,
       render: (text, record) => (
         <span
@@ -183,13 +216,11 @@ const LockStore = () => {
     {
       title: '销售/借出/赠送时间',
       dataIndex: 'allotedTime',
-      key: 'allotedTime',
       width: 160
     },
     {
       title: '办事处',
       dataIndex: 'category',
-      key: 'category',
       width: 150
     }
   ]
@@ -214,12 +245,10 @@ const LockStore = () => {
       onLoadingChange={loadingStatus => {
         loadingStatus && redoHeight()
       }}
-      request={async params => {
-        const {
-          code = -1,
-          data: { longle = [], log = [], total = 0 } = { longle: [], log: [], total: 0 }
-        } = await queryLock({ ...params })
-        setState({ ...state, data: longle, log, total })
+      request={async (params, sort, filter) => {
+        const srotOrder = refactorSortField(sort)
+        const { code = -1, data: { longle = [], total = 0 } = { longle: [], total: 0 } } =
+          await queryLock({ ...params, ...srotOrder, ...filter })
         return {
           data: longle,
           success: code === consts.RET_CODE.SUCCESS,
@@ -239,7 +268,30 @@ const LockStore = () => {
               onSearch={handleSearch}
             />
           </Tooltip>
-        )
+        ),
+        actions: [
+          <DatePicker
+            key="date"
+            bordered={false}
+            placeholder="请选择出库时间"
+            onChange={e =>
+              setState({
+                ...state,
+                params: { ...state.params, makeDay: e ? e.format('YYYY-MM-DD') : '' }
+              })
+            }
+          />,
+          <Select
+            key="select"
+            bordered={false}
+            style={{ width: '150px' }}
+            labelInValue={true}
+            allowClear={true}
+            placeholder="请选择产品"
+            options={state.prodList.map(item => ({ value: item.title }))}
+            onChange={e => setState({ ...state, params: { ...state.params, product: e } })}
+          />
+        ]
       }}
     />
     // {/* <Locks onClose={hideDrawer} visible={state.visible} onCreate={onCreate} id={state.id} /> */}

+ 1 - 1
src/pages/workbench/Dashboard/components/LeaderBoard.jsx

@@ -111,7 +111,7 @@ const LeaderBoard = ({ loading = false, dataList = [] }) => {
           </Select>
         </div>
       }>
-      <div className="text-center border border-x-0 mt-2 p-2">{opMap[activeOp]}排行榜</div>
+      <div className="text-center border border-x-0 p-2">{opMap[activeOp]}排行榜</div>
       <div className="">
         <ProTable
           border={true}

+ 11 - 14
src/services/lock.js

@@ -1,16 +1,10 @@
 import request from '@/basic/utils/request'
-import consts from '@/consts'
 
-/**
- * 请求客户列表
- * @param {*} payload 载荷
- */
-export async function queryLock(payload) {
-  const params = { page: 1, size: consts.PAGE_SIZE, ...payload }
-  const data = await request('/software/list', {
-    params: { ...params }
+/** 请求客户列表 */
+export async function queryLock(params) {
+  return request('/software/list', {
+    params
   })
-  return data
 }
 
 /**
@@ -19,8 +13,7 @@ export async function queryLock(payload) {
  */
 export async function apiSoftwareDetail(id) {
   const params = { id }
-  const data = await request('/software/detail', { params })
-  return data
+  return request('/software/detail', { params })
 }
 
 /**
@@ -28,6 +21,10 @@ export async function apiSoftwareDetail(id) {
  * @param {string} id 软件锁记录id
  */
 export async function apiSoftwareAddLonglelog(payload) {
-  const data = await request.post('/software/add/longlelog', { data: payload })
-  return data
+  return request.post('/software/add/longlelog', { data: payload })
+}
+
+/** 获取软件锁-产品 */
+export async function querySoftwareProducts(params) {
+  return request.get('/software/product', { params })
 }