Преглед изворни кода

Merge branch 'master' of http://192.168.0.115:3000/shaogen1995/qingDao_goods into master

shaogen1995 пре 4 дана
родитељ
комит
8d6214e29e

+ 0 - 4
src/pages/Fstorehouse/F1inStorage/F1edit/index.tsx

@@ -127,10 +127,6 @@ function F1editContent() {
   return (
     <div className={styles.F1edit} id='editBox'>
       <div className='editMain'>
-        <div className='F1editStorage'>
-          <p className='F1editStorageTitle'>审批信息</p>
-        </div>
-
         {/* 顶部 */}
         {/* TODO: 借展归还待完善 */}
         <EditTop

+ 16 - 0
src/pages/Fstorehouse/F3outStorage/F3edit/index.module.scss

@@ -0,0 +1,16 @@
+.F3edit {
+  :global {
+    .F3editStorage {
+      width: 100%;
+      border-top: 1px solid #ccc;
+      padding: 15px;
+      display: flex;
+      align-items: center;
+      gap: 15px;
+    }
+    .F3editStorageTitle {
+      font-weight: 700;
+      font-size: 18px;
+    }
+  }
+}

+ 139 - 0
src/pages/Fstorehouse/F3outStorage/F3edit/index.tsx

@@ -0,0 +1,139 @@
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import { useParams } from 'react-router-dom'
+import styles from './index.module.scss'
+import EditTop from '@/pages/Zother/EditTop'
+import EditBtn from '@/pages/Zother/EditBtn'
+import { InfoProvider, useInfo } from '@/pages/Zother/InfoContext'
+import { rowArrTemp } from '@/pages/Zother/data'
+import SonGoodsList from '@/pages/Zother/SonGoodsList'
+import { F3_APIgetClueList, F3API_obj } from '@/store/action/Fstorehouse/F3outStorage'
+import { Select } from 'antd'
+import { selectObj } from '@/utils/dataChange'
+import FileArchive from '@/pages/Zother/FileArchive'
+import { F1_APIgetStorageList } from '@/store/action/Fstorehouse/F1inStorage'
+
+const rowArr = rowArrTemp('出库')
+
+function F3editContent() {
+  const { info } = useInfo() as { info: any }
+  const { key } = useParams<any>()
+  const canEdit = useMemo(() => ['1', '2'].includes(key), [key])
+  const sonGoodsListRef = useRef<any>(null)
+  const [selectStorage, setSelectStorage] = useState<any>(null)
+  const [allWarehouseList, setAllWarehouseList] = useState<any[]>([])
+  const warehouseOptions = useMemo(() => {
+    return allWarehouseList.map((i: any) => ({
+      label: i.name,
+      value: i.id,
+      managerUser: i.managerUser
+    }))
+  }, [allWarehouseList])
+
+  const handleStorageChange = useCallback(async (value: string, option: any) => {
+    setSelectStorage(option)
+  }, [])
+
+  const getStorageList = useCallback(async () => {
+    const res = await F1_APIgetStorageList()
+    setAllWarehouseList(res.data.records)
+  }, [])
+
+  useEffect(() => {
+    getStorageList()
+  }, [getStorageList])
+
+  useEffect(() => {
+    if (!info?.storageId || !allWarehouseList.length) return
+    const opt = warehouseOptions.find((o: any) => o.value === info.storageId)
+    if (opt && selectStorage?.value !== info.storageId) {
+      setSelectStorage(opt)
+    }
+  }, [info?.storageId, allWarehouseList.length, warehouseOptions, selectStorage?.value])
+
+  const getExtraData = (info: any, snaps: any[]) => {
+    return {
+      storageId: selectStorage?.value ?? undefined
+    }
+  }
+
+  return (
+    <div className={styles.F3edit} id='editBox'>
+      <div className='editMain'>
+        {/* 顶部 */}
+        {/* TODO: 借展归还待完善 */}
+        <EditTop
+          pageTxt='藏品出库'
+          rowArr={rowArr}
+          APIobj={F3API_obj}
+          fileUpInfo={{ myUrl: 'cms/orderSite/out/upload', dirCode: 'outStorage' }}
+        />
+
+        <div className='F3editStorage'>
+          <p className='F3editStorageTitle'>*出库库房</p>
+          <Select
+            style={{ width: 200 }}
+            options={warehouseOptions}
+            placeholder='请选择'
+            value={selectStorage?.value}
+            onChange={handleStorageChange}
+            disabled={!canEdit}
+          />
+          {selectStorage?.managerUser && (
+            <p className='F3editStorageManager'>库房负责人:{selectStorage.managerUser}</p>
+          )}
+        </div>
+
+        {/* 藏品清单 */}
+        <SonGoodsList
+          ref={sonGoodsListRef}
+          needEdit={true}
+          btnTxt='选择藏品'
+          addShow={false}
+          goodsSonTable={[
+            ['txt', '藏品登记号', 'num'],
+            ['img', '封面', 'thumb'],
+            ['txtCTag', '藏品标签', 'tagDictId'],
+            ['txt', '藏品名称', 'name'],
+            ['select', '级别', 'level', selectObj['藏品级别']],
+            ['txtC', '类别', 'typeDictId'],
+            ['txtC', '年代', 'ageDictId'],
+            ['txtC', '质地', 'textureDictId'],
+            ['select', '完残程度', 'tornLevel', selectObj['完残程度']],
+            ['ping', '数量', 'pcs', 'pcsUnitDictId'],
+            ['txt', '库房位置', 'siteLoc']
+          ]}
+          fileUpInfo={{ myUrl: 'cms/orderSite/out/upload', dirCode: 'outStorageGoods' }}
+          selectApi={F3_APIgetClueList}
+          isClueSelect={false}
+          clueShowBtnDisabled={!selectStorage?.value}
+          selectGoodsParams={{
+            storageId: selectStorage?.value
+          }}
+        />
+
+        {/* 附件归档 */}
+        <FileArchive />
+
+        {/* 底部按钮 */}
+        <EditBtn
+          path='/outStorage'
+          APIobj={F3API_obj}
+          checkListTxt='请添加藏品'
+          getExtraData={getExtraData}
+        />
+      </div>
+    </div>
+  )
+}
+
+function F3edit() {
+  return (
+    <InfoProvider>
+      <F3editContent />
+    </InfoProvider>
+  )
+}
+
+const MemoF3edit = React.memo(F3edit)
+
+export default MemoF3edit

+ 118 - 1
src/pages/Fstorehouse/F3outStorage/index.tsx

@@ -1,9 +1,126 @@
-import React from 'react'
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
+import { useHistory } from 'react-router-dom'
+import { useSelector } from 'react-redux'
+import { RootState } from '@/store'
+import TableList from '@/pages/Zother/TableList'
+import { selectObj } from '@/utils/dataChange'
+import { Button } from 'antd'
+import { tableListAuditBtnFu } from '@/utils/authority'
+import { outStorageTableC } from '@/utils/tableData'
+import { F1_APIgetStorageList } from '@/store/action/Fstorehouse/F1inStorage'
+import { F3_APIgetList } from '@/store/action/Fstorehouse/F3outStorage'
+import { baseFormData } from '@/pages/Zother/data'
+
+const F3baseFormData = baseFormData()
+
 function F3outStorage() {
+  const tableListRef = useRef<any>(null)
+  const history = useHistory()
+  // 从仓库拿数据
+  const tableInfo = useSelector((state: RootState) => state.F3outStorage.tableInfo)
+  const [allWarehouseList, setAllWarehouseList] = useState<any[]>([])
+  const warehouseOptions = useMemo(() => {
+    return allWarehouseList.map((i: any) => ({
+      label: i.name,
+      value: i.id
+    }))
+  }, [allWarehouseList])
+
+  const dataExport = () => {
+    console.log('数据导出了')
+  }
+
+  const getStorageList = async () => {
+    const res = await F1_APIgetStorageList()
+    setAllWarehouseList(res.data.records)
+  }
+
+  const tableBtnFu = useCallback(
+    (id: number | null, key: string) => {
+      history.push(`/outStorage_edit/${key}/${id}`)
+    },
+    [history]
+  )
+
+  useEffect(() => {
+    getStorageList()
+  }, [])
+
   return (
     <div className={styles.F3outStorage}>
       <div className='pageTitle'>藏品出库</div>
+
+      <TableList
+        ref={tableListRef}
+        baseFormData={F3baseFormData}
+        getListAPI={F3_APIgetList}
+        pageKey='position'
+        tableInfo={tableInfo}
+        columnsTemp={outStorageTableC}
+        rightBtnWidth={340}
+        yHeight={585}
+        searchDom={[
+          {
+            type: 'time',
+            key: ['startTime', 'endTime'],
+            placeholder: `出库日期`
+          },
+          {
+            type: 'select',
+            key: 'storageId',
+            placeholder: `相关库房`,
+            options: warehouseOptions
+          },
+          {
+            type: 'input',
+            key: 'searchKey',
+            placeholder: `请输入申请编号、发起人或藏品编号`
+          },
+          {
+            type: 'time',
+            key: ['businessStartTime', 'businessEndTime'],
+            placeholder: `发起日期`
+          },
+          {
+            type: 'select',
+            key: 'status',
+            placeholder: `申请状态`,
+            options: selectObj['藏品入库申请状态']
+          }
+        ]}
+        storyTableListToprr={({ clickSearch, resetSelectFu }) => (
+          <>
+            <Button type='primary' ghost onClick={() => tableBtnFu(null, '1')}>
+              发起申请
+            </Button>
+            <Button type='primary' onClick={dataExport}>
+              数据导出
+            </Button>
+            <Button type='primary' onClick={clickSearch}>
+              查询
+            </Button>
+            <Button onClick={resetSelectFu}>重置</Button>
+          </>
+        )}
+        storyTableLastBtn={[
+          {
+            title: '操作',
+            render: (item: any) => (
+              <>
+                <Button type='text' onClick={() => tableBtnFu(item.id, '4')}>
+                  查看
+                </Button>
+                {tableListAuditBtnFu(item) ? (
+                  <Button size='small' type='text' onClick={() => tableBtnFu(item.id, '3')}>
+                    审批
+                  </Button>
+                ) : null}
+              </>
+            )
+          }
+        ]}
+      />
     </div>
   )
 }

+ 6 - 0
src/pages/Layout/data.ts

@@ -370,5 +370,11 @@ export const routerSon: RouterTypeRow[] = [
     name: '藏品入库-详情页',
     path: '/inStorage_edit/:key/:id',
     Com: React.lazy(() => import('../Fstorehouse/F1inStorage/F1edit'))
+  },
+  {
+    id: 1030,
+    name: '藏品出库-详情页',
+    path: '/outStorage_edit/:key/:id',
+    Com: React.lazy(() => import('../Fstorehouse/F3outStorage/F3edit'))
   }
 ]

+ 8 - 2
src/pages/Zother/SonGoodsList/index.tsx

@@ -36,6 +36,9 @@ type Props = {
   needEdit?: boolean
   goodsSonTable?: any[]
   customRightBtn?: React.ReactNode
+  // 选择列表按钮是否禁用
+  clueShowBtnDisabled?: boolean
+  selectGoodsParams?: any
 }
 
 function SonGoodsList(
@@ -48,7 +51,9 @@ function SonGoodsList(
     addShow = true,
     needEdit,
     goodsSonTable,
-    customRightBtn
+    customRightBtn,
+    clueShowBtnDisabled,
+    selectGoodsParams
   }: Props,
   ref: any
 ) {
@@ -115,7 +120,7 @@ function SonGoodsList(
         ) : (
           <div>
             {customRightBtn ? customRightBtn : null}
-            <Button type='primary' onClick={() => setClueShow(true)}>
+            <Button type='primary' onClick={() => setClueShow(true)} disabled={clueShowBtnDisabled}>
               {btnTxt ? btnTxt : '从征集线索中添加'}
             </Button>
             {addShow ? (
@@ -174,6 +179,7 @@ function SonGoodsList(
       {/* 从藏品征集中添加 */}
       {clueShow ? (
         <SelectGoods
+          canObj={selectGoodsParams}
           myType={isClueSelect ? '线索' : '藏品'}
           API_getList={selectApi}
           baseFormData={isClueSelect ? sgBaseFormData : sgBaseFormDataGood}

+ 38 - 0
src/store/action/Fstorehouse/F3outStorage.ts

@@ -0,0 +1,38 @@
+import { AppDispatch } from '@/store'
+import http from '@/utils/http'
+import { APIbase } from '../layout'
+
+/**
+ * 藏品出库 - 分页列表
+ */
+export const F3_APIgetList = (data: any): any => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post('cms/orderSite/out/page', data)
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total
+      }
+
+      dispatch({ type: 'F3/getList', payload: obj })
+    }
+  }
+}
+
+export const F3API_obj = {
+  创建订单: () => APIbase('get', 'cms/orderSite/out/create'),
+  获取详情: (id: number) => APIbase('get', `cms/orderSite/out/detail/${id}`),
+  草稿: (data: any) => APIbase('post', `cms/orderSite/out/saveDraft`, data),
+  发起: (data: any) => APIbase('post', `cms/orderSite/out/saveApply`, data),
+  重新发起: (id: number) => APIbase('get', `cms/orderSite/out/reissue/${id}`),
+  审批: (data: any) => APIbase('post', `cms/orderSite/out/audit`, data),
+  撤回: (id: number) => APIbase('get', `cms/orderSite/out/revocation/${id}`),
+  删除: (id: number) => APIbase('get', `cms/orderSite/out/remove/${id}`)
+}
+
+/**
+ * 藏品总账列表-分页
+ */
+export const F3_APIgetClueList = (data: any) => {
+  return http.post('cms/orderSite/out/good/page', data)
+}

+ 28 - 0
src/store/reducer/Fstorehouse/F3outStorage.ts

@@ -0,0 +1,28 @@
+import { Typetable } from '@/pages/Zother/data'
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  tableInfo: {
+    list: [] as Typetable[],
+    total: 0
+  }
+}
+
+// 定义 action 类型
+type Props = {
+  type: 'F3/getList'
+  payload: { list: Typetable[]; total: number }
+}
+
+// reducer
+export default function Reducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case 'F3/getList':
+      return { ...state, tableInfo: action.payload }
+
+    default:
+      return state
+  }
+}

+ 2 - 0
src/store/reducer/index.ts

@@ -15,6 +15,7 @@ import E1tag from './Eculture/E1tag'
 import E2story from './Eculture/E2story'
 import G1accident from './Gmaintain/G1accident'
 import F1inStorage from './Fstorehouse/F1inStorage'
+import F3outStorage from './Fstorehouse/F3outStorage'
 import I1storageSet from './Isystem/I1storageSet'
 import I2dict from './Isystem/I2dict'
 import I3numSet from './Isystem/I3numSet'
@@ -41,6 +42,7 @@ const rootReducer = combineReducers({
   G1accident,
 
   F1inStorage,
+  F3outStorage,
 
   I1storageSet,
   I2dict,

+ 11 - 0
src/utils/tableData.ts

@@ -165,3 +165,14 @@ export const inStorageTableC = [
   ['txt', '发起日期', 'date'],
   ['select', '申请状态', 'status', selectObj['藏品入库申请状态']]
 ]
+
+// 藏品出库
+export const outStorageTableC = [
+  ['txt', '出库日期', 'createTime'],
+  ['txt', '出库库房', 'storageName'],
+  ['txt', '申请编号', 'num'],
+  ['txt', '发起部门', 'deptName'],
+  ['txt', '发起人', 'creatorName'],
+  ['txt', '发起日期', 'date'],
+  ['select', '申请状态', 'status', selectObj['藏品入库申请状态']]
+]