Prechádzať zdrojové kódy

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

shaogen1995 13 hodín pred
rodič
commit
0a4799271a

+ 16 - 0
src/pages/Dmanage/D4resource/D4edit/index.module.scss

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

+ 130 - 0
src/pages/Dmanage/D4resource/D4edit/index.tsx

@@ -0,0 +1,130 @@
+import React, { useCallback, useEffect, useMemo, useState } from 'react'
+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 SonGoodsList from '@/pages/Zother/SonGoodsList'
+import FileArchive from '@/pages/Zother/FileArchive'
+import { getDictFu, selectObj } from '@/utils/dataChange'
+import { D4_APIgetClueList, D4API_obj } from '@/store/action/Dmanage/D4resource'
+import { Checkbox } from 'antd'
+import { useParams } from 'react-router-dom'
+
+const rowArr = [
+  {
+    name: `资源使用`,
+    type: 'txt'
+  },
+  {
+    name: `使用日期`,
+    must: true,
+    key: ['dateStart', 'dateEnd'],
+    modeKey: 'dateMode',
+    type: 'DatePicker2'
+  },
+  {
+    name: '申请编号',
+    must: true,
+    key: 'num',
+    type: 'Input',
+    noNull: true //不允许输入空格
+  },
+  {
+    name: '申请类型',
+    key: 'dictIdApply',
+    type: 'Cascader',
+    options: getDictFu('资源使用')
+  },
+  {
+    name: '事由说明',
+    full: true,
+    key: 'reason',
+    type: 'TextArea'
+  },
+  {
+    name: '备注',
+    full: true,
+    key: 'remark',
+    type: 'TextArea'
+  }
+]
+
+function D4editContent() {
+  const { info } = useInfo() as { info: any }
+  const { key } = useParams<any>()
+  const [resourceType, setResourceType] = useState<string[]>(
+    key === '1' ? selectObj['附件类型'].map((v: any) => v.value) : []
+  )
+  const canEdit = useMemo(() => ['1', '2'].includes(key), [key])
+
+  const handleResourceTypeChange = useCallback((val: string[]) => {
+    setResourceType(val)
+  }, [])
+
+  const getExtraData = () => {
+    return {
+      snapType: resourceType.join(',')
+    }
+  }
+
+  useEffect(() => {
+    if (!info.snapType) return
+    setResourceType(info.snapType.split(','))
+  }, [info.snapType])
+
+  return (
+    <div className={styles.D4edit} id='editBox'>
+      <div className='editMain'>
+        {/* 顶部 */}
+        <EditTop
+          pageTxt='申请信息'
+          rowArr={rowArr}
+          APIobj={D4API_obj}
+          fileUpInfo={{ myUrl: 'cms/order/resource/upload', dirCode: 'resource' }}
+        />
+
+        <div className='D4editResource'>
+          <p className='D4editResourceTitle'>资源类型</p>
+          <Checkbox.Group
+            disabled={!canEdit}
+            options={selectObj['附件类型']}
+            value={resourceType}
+            onChange={handleResourceTypeChange}
+          />
+        </div>
+
+        {/* 藏品清单 */}
+        <SonGoodsList
+          fileUpInfo={{ myUrl: 'cms/order/resource/son/upload', dirCode: 'resourceGoods' }}
+          selectApi={D4_APIgetClueList}
+          addShow={false}
+          isClueSelect={false}
+          btnTxt='选择藏品'
+        />
+
+        {/* 附件归档 */}
+        <FileArchive />
+
+        {/* 底部按钮 */}
+        <EditBtn
+          path='/resource'
+          APIobj={D4API_obj}
+          checkListTxt='请添加藏品'
+          getExtraData={getExtraData}
+        />
+      </div>
+    </div>
+  )
+}
+
+function D4edit() {
+  return (
+    <InfoProvider>
+      <D4editContent />
+    </InfoProvider>
+  )
+}
+
+const MemoD4edit = React.memo(D4edit)
+
+export default MemoD4edit

+ 95 - 1
src/pages/Dmanage/D4resource/index.tsx

@@ -1,9 +1,103 @@
-import React from 'react'
+import React, { useCallback, useRef } from 'react'
 import styles from './index.module.scss'
 import styles from './index.module.scss'
+import TableList from '@/pages/Zother/TableList'
+import { tableListAuditBtnFu } from '@/utils/authority'
+import { selectObj } from '@/utils/dataChange'
+import { resourceTableC } from '@/utils/tableData'
+import { Button } from 'antd'
+import { baseFormData } from '@/pages/Zother/data'
+import { RootState } from '@/store'
+import { useSelector } from 'react-redux'
+import { useHistory } from 'react-router-dom'
+import { D4_APIgetList } from '@/store/action/Dmanage/D4resource'
+
+const D4baseFormData = baseFormData()
+
 function D4resource() {
 function D4resource() {
+  const tableListRef = useRef<any>(null)
+  const history = useHistory()
+  // 从仓库拿数据
+  const tableInfo = useSelector((state: RootState) => state.D4resource.tableInfo)
+
+  const dataExport = () => {
+    console.log('数据导出了')
+  }
+
+  const tableBtnFu = useCallback(
+    (id: number | null, key: string) => {
+      history.push(`/resource_edit/${key}/${id}`)
+    },
+    [history]
+  )
+
   return (
   return (
     <div className={styles.D4resource}>
     <div className={styles.D4resource}>
       <div className='pageTitle'>资源使用</div>
       <div className='pageTitle'>资源使用</div>
+
+      <TableList
+        ref={tableListRef}
+        baseFormData={D4baseFormData}
+        getListAPI={D4_APIgetList}
+        pageKey='resource'
+        tableInfo={tableInfo}
+        columnsTemp={resourceTableC}
+        rightBtnWidth={340}
+        yHeight={585}
+        searchDom={[
+          {
+            type: 'time',
+            key: ['startTime', 'endTime'],
+            placeholder: `使用日期`
+          },
+          {
+            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>
     </div>
   )
   )
 }
 }

+ 15 - 8
src/pages/Fstorehouse/F4check/F4edit/index.tsx

@@ -7,7 +7,7 @@ import { InfoProvider, useInfo } from '@/pages/Zother/InfoContext'
 import { rowArrTemp } from '@/pages/Zother/data'
 import { rowArrTemp } from '@/pages/Zother/data'
 import SonGoodsList from '@/pages/Zother/SonGoodsList'
 import SonGoodsList from '@/pages/Zother/SonGoodsList'
 import { F1_APIgetStorageList, F1API_obj } from '@/store/action/Fstorehouse/F1inStorage'
 import { F1_APIgetStorageList, F1API_obj } from '@/store/action/Fstorehouse/F1inStorage'
-import { Button, Dropdown, MenuProps, Select } from 'antd'
+import { Button, Dropdown, Select } from 'antd'
 import { selectObj } from '@/utils/dataChange'
 import { selectObj } from '@/utils/dataChange'
 import FileArchive from '@/pages/Zother/FileArchive'
 import FileArchive from '@/pages/Zother/FileArchive'
 import {
 import {
@@ -21,18 +21,21 @@ import { GoodsType } from '@/pages/Zother/SonGoodsList/data'
 import { openLink } from '@/utils/history'
 import { openLink } from '@/utils/history'
 
 
 const rowArr = rowArrTemp('入库')
 const rowArr = rowArrTemp('入库')
-const registerMenu: MenuProps['items'] = [
+const registerMenu = [
   {
   {
     key: 'accident',
     key: 'accident',
-    label: '事故登记'
+    label: '事故登记',
+    type: 'SG'
   },
   },
   {
   {
     key: 'actuality',
     key: 'actuality',
-    label: '现状登记'
+    label: '现状登记',
+    type: 'XZ'
   },
   },
   {
   {
     key: 'repair',
     key: 'repair',
-    label: '修复登记'
+    label: '修复登记',
+    type: 'XF'
   }
   }
 ]
 ]
 
 
@@ -144,7 +147,7 @@ function F1editContent() {
     if (!isLook || !info.num) return
     if (!isLook || !info.num) return
     F4_APIgetRelatedOrderList(info.num).then((res: any) => {
     F4_APIgetRelatedOrderList(info.num).then((res: any) => {
       if (res.code === 0) {
       if (res.code === 0) {
-        setRelatedOrderList(res.data.records)
+        setRelatedOrderList(res.data)
       }
       }
     })
     })
   }, [info.num, isLook])
   }, [info.num, isLook])
@@ -258,12 +261,16 @@ function F1editContent() {
             lastBtn={[
             lastBtn={[
               {
               {
                 title: '操作',
                 title: '操作',
-                render: (item: GoodsType) => {
+                render: (item: any) => {
                   return (
                   return (
                     <Button
                     <Button
                       size='small'
                       size='small'
                       type='text'
                       type='text'
-                      onClick={() => openLink(`/goodsLook/${item.id}`)}
+                      onClick={() =>
+                        openLink(
+                          `/${registerMenu.find(v => v.type === item.type)?.key}_edit/4/${item.id}?pNum=${`${item.num},${item.id}`}`
+                        )
+                      }
                     >
                     >
                       查看
                       查看
                     </Button>
                     </Button>

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

@@ -376,6 +376,12 @@ export const routerSon: RouterTypeRow[] = [
     Com: React.lazy(() => import('../Dmanage/D3writeOff/D3edit'))
     Com: React.lazy(() => import('../Dmanage/D3writeOff/D3edit'))
   },
   },
   {
   {
+    id: 440,
+    name: '资源使用-详情页',
+    path: '/resource_edit/:key/:id',
+    Com: React.lazy(() => import('../Dmanage/D4resource/D4edit'))
+  },
+  {
     id: 510,
     id: 510,
     name: '事故登记-详情页',
     name: '事故登记-详情页',
     path: '/accident_edit/:key/:id',
     path: '/accident_edit/:key/:id',

+ 6 - 3
src/pages/Zother/EditBtn/index.tsx

@@ -23,7 +23,7 @@ type Props = {
   // 其他需要校验的回调函数,返回 flag为true 表示校验不通过,txt为提示语
   // 其他需要校验的回调函数,返回 flag为true 表示校验不通过,txt为提示语
   verifyBackFu?: (info: Typetable) => { flag: boolean; txt: string; info?: any }
   verifyBackFu?: (info: Typetable) => { flag: boolean; txt: string; info?: any }
   // 页面特有数据,如 storageId,会合并到提交的 obj 中
   // 页面特有数据,如 storageId,会合并到提交的 obj 中
-  getExtraData?: (info: Typetable, snaps: GoodsType[]) => { storageId?: number; snaps?: any[] }
+  getExtraData?: (info: Typetable, snaps: GoodsType[]) => Record<string, any>
   // 第二个模块
   // 第二个模块
   isTow?: boolean
   isTow?: boolean
   // 藏品修改模块
   // 藏品修改模块
@@ -167,8 +167,11 @@ function EditBtn({
 
 
         if (getExtraData) {
         if (getExtraData) {
           const extra = getExtraData(info, snaps)
           const extra = getExtraData(info, snaps)
-          if (extra.storageId != null) obj = { ...obj, storageId: extra.storageId } as typeof obj
-          if (extra.snaps) obj = { ...obj, snaps: extra.snaps } as typeof obj
+          if (extra) {
+            const { snaps, ...rest } = extra
+            obj = { ...obj, ...rest } as typeof obj
+            if (snaps) obj = { ...obj, snaps: snaps } as typeof obj
+          }
         }
         }
 
 
         // if (1 + 1 === 2) {
         // if (1 + 1 === 2) {

+ 59 - 1
src/pages/Zother/EditInput/index.tsx

@@ -2,9 +2,11 @@ import React, { useCallback, useMemo } from 'react'
 import classNames from 'classnames'
 import classNames from 'classnames'
 import dayjs from 'dayjs'
 import dayjs from 'dayjs'
 import { useInfo } from '../InfoContext'
 import { useInfo } from '../InfoContext'
-import { Cascader, DatePicker, Input, Select } from 'antd'
+import { Cascader, DatePicker, Input, Radio, Select } from 'antd'
 import TextArea from 'antd/es/input/TextArea'
 import TextArea from 'antd/es/input/TextArea'
 
 
+const { RangePicker } = DatePicker
+
 type Props = {
 type Props = {
   item: any
   item: any
   isLook: boolean
   isLook: boolean
@@ -39,6 +41,22 @@ function EditInput({ item, isLook, isTow }: Props) {
         setInfoFu({ ...infoRes, dictIdApply: val ? val.join(',') : '' }, isTow)
         setInfoFu({ ...infoRes, dictIdApply: val ? val.join(',') : '' }, isTow)
       } else if (type === 'Select') {
       } else if (type === 'Select') {
         setInfoFu({ ...infoRes, [key]: val }, isTow)
         setInfoFu({ ...infoRes, [key]: val }, isTow)
+      } else if (type === 'DatePicker2') {
+        const keys = Array.isArray(key) ? key : [key]
+        const modeKey = item.modeKey
+        if (val?.type === 'longterm') {
+          const update: any = { [keys[0]]: '', [keys[1]]: '' }
+          if (modeKey) update[modeKey] = 'longterm'
+          setInfoFu({ ...infoRes, ...update }, isTow)
+        } else if (val?.type === 'range') {
+          const [start, end] = val?.dates || [null, null]
+          const update: any = {
+            [keys[0]]: start ? dayjs(start).format('YYYY-MM-DD') : '',
+            [keys[1]]: end ? dayjs(end).format('YYYY-MM-DD') : ''
+          }
+          if (modeKey) update[modeKey] = 'range'
+          setInfoFu({ ...infoRes, ...update }, isTow)
+        }
       }
       }
     },
     },
     [infoRes, isTow, setInfoFu]
     [infoRes, isTow, setInfoFu]
@@ -109,6 +127,46 @@ function EditInput({ item, isLook, isTow }: Props) {
             options={item.options}
             options={item.options}
             allowClear={!item.must}
             allowClear={!item.must}
           />
           />
+        ) : item.type === 'DatePicker2' ? (
+          (() => {
+            const keys = Array.isArray(item.key) ? item.key : [item.key]
+            const modeKey = item.modeKey as string | undefined
+            const startVal = infoRes[keys[0] as keyof typeof infoRes]
+            const endVal = infoRes[keys[1] as keyof typeof infoRes]
+            const modeVal = modeKey ? infoRes[modeKey as keyof typeof infoRes] : null
+            const isLongterm = modeVal === 'longterm' || (!modeVal && !startVal && !endVal)
+            const rangeValue = startVal && endVal ? [dayjs(startVal), dayjs(endVal)] : null
+            return (
+              <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
+                <Radio.Group
+                  disabled={isLook}
+                  value={isLongterm ? 'longterm' : 'range'}
+                  onChange={e => {
+                    const v = e.target.value
+                    dataChangeFu(
+                      v === 'longterm'
+                        ? { type: 'longterm' }
+                        : { type: 'range', dates: [null, null] },
+                      item
+                    )
+                  }}
+                >
+                  <Radio value='longterm'>长期</Radio>
+                  <Radio value='range'>定期</Radio>
+                </Radio.Group>
+                {!isLongterm && (
+                  <RangePicker
+                    disabled={isLook}
+                    allowClear={!item.must}
+                    value={rangeValue as [dayjs.Dayjs, dayjs.Dayjs]}
+                    onChange={dates =>
+                      dataChangeFu({ type: 'range', dates: dates || [null, null] }, item)
+                    }
+                  />
+                )}
+              </div>
+            )
+          })()
         ) : null}
         ) : null}
       </div>
       </div>
     </div>
     </div>

+ 2 - 0
src/pages/Zother/EditTop/index.module.scss

@@ -36,6 +36,8 @@
           }
           }
         }
         }
         .Edtop1rr {
         .Edtop1rr {
+          display: flex;
+          align-items: center;
           width: calc(100% - 100px);
           width: calc(100% - 100px);
           & > div {
           & > div {
             width: 100%;
             width: 100%;

+ 38 - 0
src/store/action/Dmanage/D4resource.ts

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

+ 28 - 0
src/store/reducer/Dmanage/D4resource.ts

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

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

@@ -13,6 +13,7 @@ import C4file from './Cledger/C4file'
 import D1register from './Dmanage/D1register'
 import D1register from './Dmanage/D1register'
 import D2edit from './Dmanage/D2edit'
 import D2edit from './Dmanage/D2edit'
 import D3writeOff from './Dmanage/D3writeOff'
 import D3writeOff from './Dmanage/D3writeOff'
+import D4resource from './Dmanage/D4resource'
 import E1tag from './Eculture/E1tag'
 import E1tag from './Eculture/E1tag'
 import E2story from './Eculture/E2story'
 import E2story from './Eculture/E2story'
 import G1accident from './Gmaintain/G1accident'
 import G1accident from './Gmaintain/G1accident'
@@ -46,6 +47,7 @@ const rootReducer = combineReducers({
   D1register,
   D1register,
   D2edit,
   D2edit,
   D3writeOff,
   D3writeOff,
+  D4resource,
   E1tag,
   E1tag,
   E2story,
   E2story,
 
 

+ 10 - 0
src/utils/tableData.ts

@@ -235,3 +235,13 @@ export const importDataTableC = [
   ['txt', '导入用户', 'creatorName'],
   ['txt', '导入用户', 'creatorName'],
   ['txt', '导入结果', 'fileSize']
   ['txt', '导入结果', 'fileSize']
 ]
 ]
+
+// 资源使用
+export const resourceTableC = [
+  ['txt', '使用日期', 'createTime'],
+  ['txt', '申请编号', 'num'],
+  ['txt', '发起部门', 'deptName'],
+  ['txt', '发起人', 'creatorName'],
+  ['txt', '发起日期', 'date'],
+  ['select', '申请状态', 'status', selectObj['藏品入库申请状态']]
+]