浏览代码

事故登记封装

shaogen1995 1 周之前
父节点
当前提交
db821531dc

+ 0 - 81
src/pages/Benter/B3auth/B3edit/index.module.scss

@@ -2,84 +2,3 @@
 //   :global {
 //   }
 // }
-
-.EditTop {
-  :global {
-    .EdTit {
-      padding: 15px;
-      font-weight: 700;
-      font-size: 18px;
-      display: flex;
-      justify-content: space-between;
-      .ant-btn {
-        margin-left: 15px;
-      }
-      .EdTitBtn {
-        pointer-events: none;
-      }
-    }
-
-    .Edtop1 {
-      border-top: 1px solid #ccc;
-      padding: 15px;
-      display: flex;
-      justify-content: space-between;
-      flex-wrap: wrap;
-      .Edtop1row {
-        display: flex;
-        width: 48%;
-        margin-bottom: 15px;
-        min-height: 32px;
-        line-height: 32px;
-        .Edtop1ll {
-          font-weight: 700;
-          width: 100px;
-          text-align: right;
-
-          span {
-            color: #ff4d4f;
-          }
-        }
-        .Edtop1rr {
-          width: calc(100% - 100px);
-          .ant-table-cell {
-            padding: 8px !important;
-          }
-          & > div {
-            width: 100%;
-          }
-          .ant-btn {
-            margin-right: 15px;
-          }
-        }
-      }
-      .Edtop1rowFull {
-        width: 100%;
-        .zztxtRow {
-          margin-bottom: 0;
-        }
-        .noUpThumb {
-          display: none;
-        }
-      }
-    }
-  }
-}
-
-.EditBtn {
-  position: absolute;
-  bottom: 0;
-  left: 0;
-  width: 100%;
-  height: 60px;
-  display: flex;
-  align-items: center;
-  padding: 0 40px;
-  display: flex;
-  justify-content: space-between;
-  :global {
-    .ant-btn {
-      margin-right: 15px;
-    }
-  }
-}

+ 4 - 0
src/pages/Gmaintain/G1accident/G1edit/index.module.scss

@@ -0,0 +1,4 @@
+// .G1edit {
+//   :global {
+//   }
+// }

+ 62 - 0
src/pages/Gmaintain/G1accident/G1edit/index.tsx

@@ -0,0 +1,62 @@
+import React from 'react'
+import styles from './index.module.scss'
+import { rowArrTemp } from '@/pages/Zother/data'
+import { InfoProvider } from '@/pages/Zother/InfoContext'
+import EditTop from '@/pages/Zother/EditTop'
+import { G1_APIgetClueList, G1API_obj } from '@/store/action/Gmaintain/G1accident'
+import EditBtn from '@/pages/Zother/EditBtn'
+import { G1moreList } from '../data'
+
+const rowArr = [
+  {
+    name: `事故登记`,
+    type: 'txt'
+  },
+  ...rowArrTemp('事故', undefined, '事故登记').slice(1)
+]
+
+function G1edit() {
+  return (
+    <InfoProvider>
+      <div className={styles.B3edit} id='editBox'>
+        <div className='editMain'>
+          {/* 顶部 */}
+          <EditTop
+            pageTxt='事故登记'
+            rowArr={rowArr}
+            APIobj={G1API_obj}
+            fileUpInfo={{ myUrl: 'cms/orderAccident/upload', dirCode: 'accident' }}
+            // 第二个模块
+            moreDom={{
+              txt: '事故报告',
+              API: G1_APIgetClueList,
+              domList: G1moreList,
+              myUrl: 'cms/orderAccident/son/upload',
+              dirCode: 'accidentSon'
+            }}
+          />
+
+          {/* 底部按钮 */}
+          <EditBtn
+            path='/accident'
+            APIobj={G1API_obj}
+            checkListTxt='请选择关联藏品'
+            verifyBackFu={info => {
+              const res = { flag: false, txt: '' }
+              if (!info.member) {
+                res.flag = true
+                res.txt = '请输入鉴定人员'
+              }
+
+              return res
+            }}
+          />
+        </div>
+      </div>
+    </InfoProvider>
+  )
+}
+
+const MemoG1edit = React.memo(G1edit)
+
+export default MemoG1edit

+ 62 - 0
src/pages/Gmaintain/G1accident/data.ts

@@ -0,0 +1,62 @@
+// 获取盘点单列表
+let panDianList: any = []
+
+const getPanDianListFu = () => {
+  console.log('xxxxx')
+  panDianList = [
+    {
+      value: 'jack',
+      label: 'Jack'
+    },
+    {
+      value: 'lucy',
+      label: 'Lucy'
+    },
+    {
+      value: 'tom',
+      label: 'Tom'
+    }
+  ]
+}
+getPanDianListFu()
+
+export const G1moreList = [
+  {
+    name: '关联盘点',
+    type: 'Select',
+    key: 'oderNum',
+    placeholder: '请搜索盘点申请编号',
+    // 待完善sg-等陈磊写完盘点----已完成的盘点单列表
+    options: panDianList
+  },
+  {
+    name: '责任人',
+    type: 'Input',
+    key: 'userName'
+  },
+  {
+    name: '事故经过',
+    type: 'TextArea',
+    key: 'process',
+    full: true
+  },
+
+  {
+    name: '事故前&emsp;<br/>藏品状态',
+    type: 'TextArea',
+    key: 'beforeInfo',
+    full: true
+  },
+  {
+    name: '事故后&emsp;<br/>藏品状态',
+    type: 'TextArea',
+    key: 'afterInfo',
+    full: true
+  },
+  {
+    name: '备注',
+    type: 'TextArea',
+    key: 'remark',
+    full: true
+  }
+]

+ 4 - 4
src/pages/Gmaintain/G1accident/index.module.scss

@@ -1,4 +1,4 @@
-.G1accident {
-  :global {
-  }
-}
+// .G1accident {
+//   :global {
+//   }
+// }

+ 23 - 0
src/pages/Gmaintain/G1accident/index.tsx

@@ -1,9 +1,32 @@
 import React from 'react'
 import styles from './index.module.scss'
+import { baseFormData, topSearch } from '@/pages/Zother/data'
+import { useSelector } from 'react-redux'
+import { RootState } from '@/store'
+import TableList from '@/pages/Zother/TableList'
+import { G1_APIgetList } from '@/store/action/Gmaintain/G1accident'
+import { baseTableC } from '@/utils/tableData'
+
+const search = topSearch('事故')
+
+const baseFormDataRes = baseFormData()
+
 function G1accident() {
+  // 从仓库拿数据
+  const tableInfo = useSelector((state: RootState) => state.G1accident.tableInfo)
+
   return (
     <div className={styles.G1accident}>
       <div className='pageTitle'>事故登记</div>
+      <TableList
+        baseFormData={baseFormDataRes}
+        getListAPI={G1_APIgetList}
+        pageKey='accident'
+        tableInfo={tableInfo}
+        columnsTemp={baseTableC('事故')}
+        yHeight={585}
+        searchDom={search}
+      />
     </div>
   )
 }

+ 40 - 3
src/pages/Isystem/I6role/I6edit.tsx

@@ -7,6 +7,8 @@ import classNmaes from 'classnames'
 import { MessageFu } from '@/utils/message'
 import { I6_APIgetAddTreeList, I6_APIgetInfo, I6_APIsave } from '@/store/action/Isystem/I6role'
 import { I6processChildren, TypeI6Role } from './data'
+import { I1_APIwarehouseSimpleList } from '@/store/action/Isystem/I1storageSet'
+import { Typetable } from '@/pages/Zother/data'
 
 type Props = {
   sId: number
@@ -36,8 +38,21 @@ function I6edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
   // 藏品可见权限
   const [scopeStorage, setScopeStorage] = useState(0)
   // 与库房相关的藏品id
-  // 待完善sg-从库房拿列表信息(等陈磊写完)
-  const [scopeStorageIds, setScopeStorageIds] = useState<number[]>([])
+
+  const getScopeStorageList = useCallback(async () => {
+    const res = await I1_APIwarehouseSimpleList({ pageNum: 1, pageSize: 99999 })
+    if (res.code === 0) {
+      setScopeStorageList(res.data.records || [])
+    }
+  }, [])
+
+  useEffect(() => {
+    getScopeStorageList()
+  }, [getScopeStorageList])
+
+  // 从库房拿列表信息
+  const [scopeStorageList, setScopeStorageList] = useState<Typetable[]>([])
+  const [scopeStorageIds, setScopeStorageIds] = useState<Number[]>([])
 
   const otherIdsFu = useCallback((data: TypeI6Role[]) => {
     setGoodIds(I6processChildren(data, 330, '藏品信息'))
@@ -332,7 +347,10 @@ function I6edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
                 <Radio.Group
                   value={scopeStorage}
                   onChange={e => {
-                    if (e.target.value === 2 && (!scopeStorageIds || scopeStorageIds.length === 0))
+                    if (
+                      e.target.value === 2 &&
+                      (!scopeStorageList || scopeStorageList.length === 0)
+                    )
                       return MessageFu.warning('暂无库房信息,请先去库房设置中添加')
                     setScopeStorage(e.target.value)
                   }}
@@ -341,6 +359,25 @@ function I6edit({ sId, closeFu, addTableFu, editTableFu }: Props) {
                     { value: 2, label: '仅与库房相关的藏品' }
                   ]}
                 />
+                {scopeStorage === 2 && (
+                  <div className='I6eboxrrBoxKuFang'>
+                    {scopeStorageList.map(v => (
+                      <Checkbox
+                        key={v.id}
+                        checked={scopeStorageIds.includes(v.id)}
+                        onChange={e => {
+                          if (scopeStorageIds.includes(v.id)) {
+                            setScopeStorageIds(scopeStorageIds.filter(id => id !== v.id))
+                          } else {
+                            setScopeStorageIds([...scopeStorageIds, v.id])
+                          }
+                        }}
+                      >
+                        {v.name}
+                      </Checkbox>
+                    ))}
+                  </div>
+                )}
               </div>
             </div>
           </div>

+ 8 - 0
src/pages/Isystem/I6role/index.module.scss

@@ -153,6 +153,14 @@
             .I6eboxrrTit {
               padding-left: 0;
             }
+            .I6eboxrrBoxKuFang {
+              margin-top: 5px;
+              padding-top: 5px;
+              border-top: 1px solid #ccc;
+              .ant-checkbox-wrapper {
+                margin-bottom: 5px;
+              }
+            }
           }
         }
         .I6eboxrr2 {

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

@@ -353,7 +353,12 @@ export const routerSon: RouterTypeRow[] = [
     path: '/writeOff_edit/:key/:id',
     Com: React.lazy(() => import('../Dmanage/D3writeOff/D3edit'))
   },
-
+  {
+    id: 510,
+    name: '事故登记-详情页',
+    path: '/accident_edit/:key/:id',
+    Com: React.lazy(() => import('../Gmaintain/G1accident/G1edit'))
+  },
   {
     id: 602,
     name: '故事管理-详情页',

+ 42 - 17
src/pages/Zother/EditInput/index.tsx

@@ -1,17 +1,22 @@
-import React, { useCallback } from 'react'
+import React, { useCallback, useMemo } from 'react'
 import classNames from 'classnames'
 import dayjs from 'dayjs'
 import { useInfo } from '../InfoContext'
-import { Cascader, DatePicker, Input } from 'antd'
+import { Cascader, DatePicker, Input, Select } from 'antd'
 import TextArea from 'antd/es/input/TextArea'
 
 type Props = {
   item: any
   isLook: boolean
+  isTow?: boolean //是否是第二个模块
 }
 
-function EditInput({ item, isLook }: Props) {
-  const { info, setInfoFu } = useInfo()
+function EditInput({ item, isLook, isTow }: Props) {
+  const { info, info2, setInfoFu } = useInfo()
+
+  const infoRes = useMemo(() => {
+    return isTow ? info2 : info
+  }, [info, info2, isTow])
 
   // 数据改变
   const dataChangeFu = useCallback(
@@ -20,37 +25,43 @@ function EditInput({ item, isLook }: Props) {
       const key = item.key
 
       if (type === 'DatePicker') {
-        setInfoFu({ ...info, [key]: dayjs(val).format('YYYY-MM-DD') })
+        setInfoFu({ ...infoRes, [key]: dayjs(val).format('YYYY-MM-DD') }, isTow)
       } else if (['TextArea', 'Input'].includes(type)) {
         const varRes = item.noNull ? val.replace(/\s+/g, '') : val
-        setInfoFu({
-          ...info,
-          [key]: varRes
-        })
+        setInfoFu(
+          {
+            ...infoRes,
+            [key]: varRes
+          },
+          isTow
+        )
       } else if (type === 'Cascader') {
-        setInfoFu({ ...info, dictIdApply: val ? val.join(',') : '' })
+        setInfoFu({ ...infoRes, dictIdApply: val ? val.join(',') : '' }, isTow)
+      } else if (type === 'Select') {
+        setInfoFu({ ...infoRes, [key]: val }, isTow)
       }
     },
-    [info, setInfoFu]
+    [infoRes, isTow, setInfoFu]
   )
 
   return (
     <div className={classNames('Edtop1row', item.full ? 'Edtop1rowFull' : '')}>
       <div className='Edtop1ll'>
         {item.must ? <span>* </span> : null}
-        {item.name}:
+        <i dangerouslySetInnerHTML={{ __html: item.name + ':' }}></i>
       </div>
 
       <div className='Edtop1rr'>
         {item.type === 'txt' ? (
           <>
-            {dayjs(info.createTime).format('YYYY年MM月DD日')}-{info.deptName}-{info.creatorName}
+            {dayjs(infoRes.createTime).format('YYYY年MM月DD日')}-{infoRes.deptName}-
+            {infoRes.creatorName}
           </>
         ) : item.type === 'DatePicker' ? (
           <DatePicker
             disabled={isLook}
             allowClear={!item.must}
-            value={dayjs(info[item.key as 'date'])}
+            value={dayjs(infoRes[item.key as 'date'])}
             onChange={e => dataChangeFu(e, item)}
             disabledDate={current => current && current > dayjs().endOf('day')}
           />
@@ -58,7 +69,7 @@ function EditInput({ item, isLook }: Props) {
           <Input
             readOnly={isLook}
             placeholder={isLook ? '(空)' : '请输入'}
-            value={info[item.key as 'date']}
+            value={infoRes[item.key as 'date']}
             onChange={e => dataChangeFu(e.target.value, item)}
             maxLength={item.maxLength || 30}
             showCount
@@ -71,18 +82,32 @@ function EditInput({ item, isLook }: Props) {
             placeholder={isLook ? '(空)' : '请选择'}
             fieldNames={{ label: 'name', value: 'id', children: 'children' }}
             allowClear={!item.must}
-            value={info[item.key as 'date'] ? (info[item.key as 'date'] as string).split(',') : []}
+            value={
+              infoRes[item.key as 'date'] ? (infoRes[item.key as 'date'] as string).split(',') : []
+            }
             onChange={e => dataChangeFu(e, item)}
           />
         ) : item.type === 'TextArea' ? (
           <TextArea
             readOnly={isLook}
             placeholder={isLook ? '(空)' : '请输入'}
-            value={info[item.key as 'date']}
+            value={infoRes[item.key as 'date']}
             onChange={e => dataChangeFu(e.target.value, item)}
             maxLength={item.maxLength || 500}
             showCount
           />
+        ) : item.type === 'Select' ? (
+          <Select
+            disabled={isLook}
+            showSearch // 启用搜索功能
+            filterOption={(input: any, option: any) =>
+              (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
+            }
+            placeholder={(isLook ? '(空)' : item.placeholder) || '请选择'}
+            onChange={e => dataChangeFu(e, item)}
+            options={item.options}
+            allowClear={!item.must}
+          />
         ) : null}
       </div>
     </div>

+ 1 - 1
src/pages/Zother/EditTop/index.tsx

@@ -247,7 +247,7 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
                 </div>
 
                 {moreDom.domList.map((item, index) => (
-                  <EditInput key={index} item={item} isLook={isLook} />
+                  <EditInput key={index} item={item} isLook={isLook} isTow={true} />
                 ))}
 
                 {/* 附件 */}

+ 15 - 6
src/pages/Zother/InfoContext.tsx

@@ -4,7 +4,8 @@ import { GoodsType } from './SonGoodsList/data'
 
 type InfoContextValue = {
   info: Typetable
-  setInfoFu: (info: Typetable | ((prevInfo: Typetable) => Typetable)) => void
+  info2: Typetable
+  setInfoFu: (info: Typetable | ((prevInfo: Typetable) => Typetable), isTow?: boolean) => void
   snaps: GoodsType[]
   setSnapsFu: (snaps: GoodsType[]) => void
   timeKey: number
@@ -40,16 +41,23 @@ export function InfoProvider({ children }: Props) {
   // 顶部信息
   const [info, setInfo] = useState({} as Typetable)
 
+  // 第二个模块的信息
+  const [info2, setInfo2] = useState({} as Typetable)
+
   // useEffect(() => {
   //   console.log('xxxxxxxx', info)
   // }, [info])
 
   const setInfoFu = useCallback(
-    (newInfoOrUpdater: Typetable | ((prevInfo: Typetable) => Typetable)) => {
-      if (typeof newInfoOrUpdater === 'function') {
-        setInfo(newInfoOrUpdater)
+    (newInfoOrUpdater: Typetable | ((prevInfo: Typetable) => Typetable), isTow?: boolean) => {
+      if (isTow) {
+        setInfo2(newInfoOrUpdater)
       } else {
-        setInfo(newInfoOrUpdater)
+        if (typeof newInfoOrUpdater === 'function') {
+          setInfo(newInfoOrUpdater)
+        } else {
+          setInfo(newInfoOrUpdater)
+        }
       }
     },
     []
@@ -65,6 +73,7 @@ export function InfoProvider({ children }: Props) {
   const value = useMemo(
     () => ({
       info,
+      info2,
       setInfoFu,
       snaps,
       setSnapsFu,
@@ -73,7 +82,7 @@ export function InfoProvider({ children }: Props) {
       auditInfo,
       setAuditInfoFu
     }),
-    [auditInfo, info, setAuditInfoFu, setInfoFu, setSnapsFu, setTimeKeyFu, snaps, timeKey]
+    [auditInfo, info, info2, setAuditInfoFu, setInfoFu, setSnapsFu, setTimeKeyFu, snaps, timeKey]
   )
 
   return <InfoContext.Provider value={value}>{children}</InfoContext.Provider>

+ 5 - 3
src/pages/Zother/data.ts

@@ -79,7 +79,7 @@ export const topSearch = (txt: string, can?: { [x: number]: string | string[] })
 }
 
 // 查看页面顶部字段 通用部分
-export const rowArrTemp = (txt: string, can?: { [x: number]: string }) => {
+export const rowArrTemp = (txt: string, can?: { [x: number]: string }, txt2?: string) => {
   const canArr = ['date', 'num', 'dictIdApply', 'reason', 'remark']
 
   if (can) {
@@ -110,7 +110,7 @@ export const rowArrTemp = (txt: string, can?: { [x: number]: string }) => {
       name: '申请类型',
       key: canArr[2],
       type: 'Cascader',
-      options: getDictFu(`藏品${txt}`)
+      options: getDictFu(txt2 ? txt2 : `藏品${txt}`)
     },
     {
       name: '事由说明',
@@ -162,7 +162,6 @@ export type Typetable = {
   dictIdApply?: any
   fileIds?: any
   files: FileListType[]
-  // 待完善sg
   files2: FileListType[]
   goodIds: string
   id: number
@@ -180,6 +179,9 @@ export type Typetable = {
 
   // 藏品鉴定
   member: string
+
+  // 库房列表
+  name: string
 }
 
 // 上传的附近路径和文件夹名字

+ 38 - 0
src/store/action/Gmaintain/G1accident.ts

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

+ 28 - 0
src/store/reducer/Gmaintain/G1accident.ts

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

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

@@ -13,6 +13,8 @@ import D3writeOff from './Dmanage/D3writeOff'
 import E1tag from './Eculture/E1tag'
 import E2story from './Eculture/E2story'
 
+import G1accident from './Gmaintain/G1accident'
+
 import I1storageSet from './Isystem/I1storageSet'
 import I2dict from './Isystem/I2dict'
 import I3numSet from './Isystem/I3numSet'
@@ -34,6 +36,7 @@ const rootReducer = combineReducers({
   D3writeOff,
   E1tag,
   E2story,
+  G1accident,
 
   I1storageSet,
   I2dict,