shaogen1995 преди 3 месеца
родител
ревизия
b4caced928

+ 12 - 1
src/pages/B_enterTibet/B1collect/B1edit/index.tsx

@@ -288,6 +288,9 @@ function B1edit() {
     )
   }, [delFu, lookBtnFu, lookJumpFu, topInfo])
 
+  // 申请记录
+  const [auditsShow, setAuditsShow] = useState(false)
+
   return (
     <div className={styles.B1edit}>
       <div className='pageTitle'>藏品征集-{Reflect.get(pageTitTxtObj, key)}</div>
@@ -426,11 +429,19 @@ function B1edit() {
         {['3', '4'].includes(key) ? <B1appraisal /> : null}
 
         {/* 申请流程 */}
-        {['3', '4'].includes(key) ? <B3flowTable tableArr={topInfo.audits || []} /> : null}
+        {auditsShow ? (
+          <B3flowTable tableArr={topInfo.audits || []} closeFu={() => setAuditsShow(false)} />
+        ) : null}
       </div>
 
       {/* 底部按钮 */}
       <div className='B1btn'>
+        {['3', '4'].includes(key) && topInfo.audits && topInfo.audits.length ? (
+          <Button type='primary' onClick={() => setAuditsShow(true)}>
+            申请记录
+          </Button>
+        ) : null}
+
         {key === '4' ? (
           lookBtn
         ) : (

+ 33 - 11
src/pages/B_enterTibet/B3flowTable/index.module.scss

@@ -1,16 +1,38 @@
 .B3flowTable {
-  padding-right: 20px;
-  margin-top: 24px;
-  padding-bottom: 40px;
+  position: absolute;
+  z-index: 999;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  background-color: rgba(0, 0, 0, 0.6);
+  padding: 50px 80px;
+  border-radius: 10px;
+
   :global {
-    .B3Ftop {
-      color: var(--themeColor);
-      font-size: 18px;
-      font-weight: 700;
-      padding-left: 18px;
-      margin-bottom: 24px;
-      border-bottom: 1px solid #ccc;
-      padding-bottom: 15px;
+    .B3Fbox {
+      width: 100%;
+      height: 100%;
+      background-color: #fff;
+      border-radius: 10px;
+      padding: 20px;
+      .B3Ftop {
+        margin-bottom: 24px;
+        border-bottom: 1px solid #ccc;
+        padding-bottom: 15px;
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        & > div {
+          color: var(--themeColor);
+          font-size: 18px;
+          font-weight: 700;
+          padding-left: 18px;
+        }
+      }
+      .ant-table-cell {
+        padding: 8px !important;
+      }
     }
   }
 }

+ 20 - 8
src/pages/B_enterTibet/B3flowTable/index.tsx

@@ -21,9 +21,10 @@ export type B3flowTableType = {
 }
 type Props = {
   tableArr: B3flowTableType[]
+  closeFu: () => void
 }
 
-function B3flowTable({ tableArr }: Props) {
+function B3flowTable({ tableArr, closeFu }: Props) {
   // const { key, id } = useParams<any>()
 
   const tableLastBtn = useMemo(() => {
@@ -55,14 +56,25 @@ function B3flowTable({ tableArr }: Props) {
   const [look, setLook] = useState('')
 
   return (
-    <div className={styles.B3flowTable} hidden={tableArr.length === 0}>
-      <div className='B3Ftop'>申请流程</div>
+    <div className={styles.B3flowTable}>
+      <div className='B3Fbox'>
+        <div className='B3Ftop'>
+          <div>申请记录</div>
+          <Button onClick={closeFu}>关闭</Button>
+        </div>
+        {/* 表格 */}
+        <MyTable
+          yHeight={570}
+          classKey='B3flowTable'
+          list={tableArr}
+          columnsTemp={B3FtableC}
+          lastBtn={tableLastBtn}
+          pagingInfo={false}
+        />
 
-      {/* 表格 */}
-      <MyTable list={tableArr} columnsTemp={B3FtableC} lastBtn={tableLastBtn} pagingInfo={false} />
-
-      {/* 查看富文本 */}
-      {look ? <X2lookText closeFu={() => setLook('')} text={look} /> : null}
+        {/* 查看富文本 */}
+        {look ? <X2lookText closeFu={() => setLook('')} text={look} /> : null}
+      </div>
     </div>
   )
 }

+ 103 - 0
src/pages/E_goodsStorage/E1accident/E1edit/index.module.scss

@@ -0,0 +1,103 @@
+.E1edit {
+  background-color: #fff;
+  border-radius: 10px;
+  padding: 15px 24px 0px;
+  :global {
+    .E1Tit {
+      font-size: 18px;
+      font-weight: 700;
+      padding-bottom: 10px;
+      padding-left: 18px;
+      border-bottom: 1px solid #ccc;
+      margin-bottom: 17px;
+      color: var(--themeColor);
+      .ant-btn {
+        margin-left: 15px;
+        pointer-events: none;
+      }
+    }
+    .E1main {
+      width: 100%;
+      height: calc(100% - 70px);
+      overflow-y: auto;
+      padding-bottom: 40px;
+
+      .E1rowAll {
+        display: flex;
+        justify-content: space-between;
+        align-items: self-start;
+        font-size: 16px;
+        flex-wrap: wrap;
+        .E1row {
+          width: 48%;
+          display: flex;
+          align-items: center;
+          margin-bottom: 20px;
+          min-height: 32px;
+          .E1rowll {
+            width: 110px;
+            text-align: right;
+            font-weight: 700;
+            & > span {
+              color: #ff4e1f;
+            }
+          }
+          .E1rowrr {
+            width: calc(100% - 110px);
+            .ant-input-affix-wrapper {
+              width: 300px;
+            }
+            .ant-select {
+              width: 300px;
+            }
+          }
+        }
+        .E1row2 {
+          align-items: self-start;
+          .E1rowll {
+            position: relative;
+            top: 3px;
+          }
+        }
+        .E1row3 {
+          position: relative;
+          top: 4px;
+        }
+
+        .E1rowFull {
+          width: 100%;
+          align-items: self-start;
+          margin-bottom: 0;
+          .E1rowll {
+            position: relative;
+            top: 3px;
+          }
+        }
+      }
+      // 藏品清单
+      .E1googsBox {
+        padding-right: 20px;
+        .D1GtNum {
+          cursor: pointer;
+          text-decoration: underline;
+          // &:hover {
+          //   color: var(--themeColor);
+          // }
+        }
+
+        .D1GtNumAc {
+          color: var(--themeColor);
+        }
+      }
+    }
+
+    .E1btn {
+      position: absolute;
+      bottom: 20px;
+      left: 134px;
+      .ant-btn {
+        margin-right: 20px;
+      }
+    }
+  }
+}

+ 569 - 0
src/pages/E_goodsStorage/E1accident/E1edit/index.tsx

@@ -0,0 +1,569 @@
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
+import styles from './index.module.scss'
+import { pageTitTxtObj } from '@/pages/D_storeManage/D4impStor/D4edit'
+import { useParams } from 'react-router-dom'
+import { Button, DatePicker, Input, Select } from 'antd'
+import { statusObj } from '@/utils/tableData'
+import { FourTableType } from '@/pages/B_enterTibet/B3_4page/type'
+import dayjs from 'dayjs'
+import { selectObj } from '@/utils/select'
+import Z3upFiles from '@/components/Z3upFiles'
+import ZRichTexts from '@/components/ZRichTexts'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import history, { btnFlagFu2 } from '@/utils/history'
+import { MessageFu } from '@/utils/message'
+import X3auditInfo from '@/pages/X_stock/X3auditInfo'
+import {
+  E1_APIcreate,
+  E1_APIdel,
+  E1_APIgetGoodsList,
+  E1_APIgetInfo,
+  E1_APIrevocation,
+  E1_APIsaveApply,
+  E1_APIsaveAudit,
+  E1_APIsaveCreate,
+  E1_APIsaveDraft
+} from '@/store/action/E1accident'
+import { EXbtnFu } from '@/utils/EXBtn'
+import B3flowTable from '@/pages/B_enterTibet/B3flowTable'
+function E1edit() {
+  const { key, id } = useParams<any>()
+  // key:1 新增 2编辑 3审批 4查看
+
+  // 事故藏品选择编号类型
+
+  const [goodsArr, setGoodsArr] = useState<{ value: string; label: string; num: string }[]>([])
+
+  const numNameChangeFu = useCallback(async (val: string) => {
+    const res = await E1_APIgetGoodsList(val)
+
+    if (res.code === 0) {
+      const arr = res.data || []
+      setGoodsArr(
+        arr.map((v: any) => ({
+          num: v.num,
+          label: v.name,
+          value: v.id + ''
+        }))
+      )
+    }
+  }, [])
+
+  // 滚到顶部
+  const sollrDom = useRef<HTMLDivElement>(null)
+
+  // 顶部数据
+  const [topInfo, setTopInfo] = useState({} as FourTableType)
+
+  // 创建订单
+  const creatFu = useCallback(async () => {
+    const res = await E1_APIcreate()
+    if (res.code === 0) {
+      setTopInfo(res.data)
+    }
+  }, [])
+
+  // 获取详情
+  const getInfoFu = useCallback(async () => {
+    const res = await E1_APIgetInfo(id)
+    if (res.code === 0) {
+      const data = res.data
+
+      setTopInfo(data)
+
+      // 设置富文本
+      ZRichTextRefQian.current?.ritxtShowFu(JSON.parse(data.authInfoRtf || '{}'))
+      ZRichTextRefHou.current?.ritxtShowFu(JSON.parse(data.authResultRtf || '{}'))
+      ZRichTextRefYuan.current?.ritxtShowFu(JSON.parse(data.reason || '{}'))
+      ZRichTextRef.current?.ritxtShowFu(JSON.parse(data.rtf || '{}'))
+
+      if (data.numName) numNameChangeFu(data.numName)
+    }
+  }, [id, numNameChangeFu])
+
+  useEffect(() => {
+    if (key === '1') creatFu()
+    else getInfoFu()
+
+    if (sollrDom.current) sollrDom.current.scrollTop = 0
+  }, [creatFu, getInfoFu, key])
+
+  const pageTitTxt = useMemo(() => {
+    return Reflect.get(pageTitTxtObj, key)
+  }, [key])
+
+  const timeChange = useCallback(
+    (e: any) => {
+      setTopInfo({ ...topInfo, date: dayjs(e).format('YYYY-MM-DD') })
+    },
+    [topInfo]
+  )
+
+  // 上传附件的ref
+  const filesRef = useRef<any>(null)
+  // const filesRes = filesRef.current.filesIdRes();
+
+  // 事故前的ref
+  const ZRichTextRefQian = useRef<any>(null)
+
+  // 事故后的ref
+  const ZRichTextRefHou = useRef<any>(null)
+
+  // 事故原因及经过
+  const ZRichTextRefYuan = useRef<any>(null)
+
+  // 备注的ref
+  const ZRichTextRef = useRef<any>(null)
+
+  // 审批意见的ref
+  const ZAuditRef = useRef<any>(null)
+
+  // 审批的sta
+  const [auditSta, setAuDitSta] = useState('')
+
+  // 字段的校验
+  const checkFu = useCallback(() => {
+    if (!topInfo.date) {
+      MessageFu.warning('请选择事故时间')
+      return true
+    }
+    if (!topInfo.sonTypeName) {
+      MessageFu.warning('请输入事故责任')
+      return true
+    }
+    if (!topInfo.numName || !topInfo.goodsIds) {
+      MessageFu.warning('请选择事故藏品')
+      return true
+    }
+  }, [topInfo])
+
+  // 新增的底部按钮点击
+  const btnClickFu = useCallback(
+    async (val: '草稿' | '创建' | '保存' | '审批') => {
+      if (checkFu()) {
+        if (sollrDom.current) sollrDom.current.scrollTop = 0
+        return
+      }
+
+      if (val === '审批') {
+        // console.log('审批信息富文本', rtf2)
+        if (!auditSta) {
+          if (sollrDom.current) sollrDom.current.scrollTop = 0
+          return MessageFu.warning('请选择审批结果')
+        }
+        const rtf2 = ZAuditRef.current?.resData()
+
+        const res = await E1_APIsaveAudit({
+          orderId: topInfo.id,
+          rtfOpinion: rtf2,
+          status: auditSta === '同意' ? 1 : 2
+        })
+
+        if (res.code === 0) {
+          MessageFu.success('审批成功')
+          // 跳详情页
+          history.push(`/accident_edit/4/${topInfo.id}`)
+        }
+      } else {
+        // 多个富文本
+        const rtfQian = ZRichTextRefQian.current?.fatherBtnOkFu() || { flag: true }
+        const rtfHou = ZRichTextRefHou.current?.fatherBtnOkFu() || { flag: true }
+        const rtfYuan = ZRichTextRefYuan.current?.fatherBtnOkFu() || { flag: true }
+        const rtf1 = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
+
+        // 上传附件
+        const filesRes = filesRef.current.filesIdRes()
+
+        const obj = {
+          ...topInfo,
+          authInfoRtf: JSON.stringify(rtfQian.val || ''),
+          authResultRtf: JSON.stringify(rtfHou.val || ''),
+          reason: JSON.stringify(rtfYuan.val || ''),
+          rtf: JSON.stringify(rtf1.val || ''),
+          fileIds: filesRes.join(',')
+        }
+        // console.log(123, obj)
+
+        // if (1 + 1 === 2) return
+
+        if (val === '草稿') {
+          // 存草稿 当前页保存 不跳转
+          const res = await E1_APIsaveDraft(obj)
+          if (res.code === 0) {
+            MessageFu.success('草稿保存成功')
+          }
+        } else {
+          const res = val === '创建' ? await E1_APIsaveCreate(obj) : await E1_APIsaveApply(obj)
+          if (res.code === 0) {
+            MessageFu.success(`${val}成功`)
+            // 跳到详情页
+            history.push(`/accident_edit/4/${topInfo.id}`)
+          }
+        }
+      }
+    },
+    [auditSta, checkFu, topInfo]
+  )
+
+  // 查看的按钮创建-提交-撤回
+  const lookBtnFu = useCallback(
+    async (val: '创建' | '提交' | '撤回') => {
+      // 多个富文本
+      const rtfQian = ZRichTextRefQian.current?.fatherBtnOkFu() || { flag: true }
+      const rtfHou = ZRichTextRefHou.current?.fatherBtnOkFu() || { flag: true }
+      const rtfYuan = ZRichTextRefYuan.current?.fatherBtnOkFu() || { flag: true }
+      const rtf1 = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
+
+      // 上传附件
+      const filesRes = filesRef.current.filesIdRes()
+      const obj = {
+        ...topInfo,
+        authInfoRtf: JSON.stringify(rtfQian.val || ''),
+        authResultRtf: JSON.stringify(rtfHou.val || ''),
+        reason: JSON.stringify(rtfYuan.val || ''),
+        rtf: JSON.stringify(rtf1.val || ''),
+        fileIds: filesRes.join(',')
+      }
+
+      const res =
+        val === '创建'
+          ? await E1_APIsaveCreate(obj)
+          : val === '提交'
+          ? await E1_APIsaveApply(obj)
+          : await E1_APIrevocation(id)
+
+      if (res.code === 0) {
+        if (sollrDom.current) sollrDom.current.scrollTop = 0
+        MessageFu.success(val + '成功')
+        getInfoFu()
+      }
+    },
+    [getInfoFu, id, topInfo]
+  )
+
+  // 查看模式点击删除
+  const delFu = useCallback(async () => {
+    const res = await E1_APIdel(id)
+    if (res.code === 0) {
+      MessageFu.success('删除成功')
+      history.push('/accident')
+    }
+  }, [id])
+
+  // 查看模式点击审批 编辑
+  const lookJumpFu = useCallback(
+    (val: '审批' | '编辑') => {
+      history.push(`/accident_edit/${val === '审批' ? 3 : 2}/${id}`)
+      MessageFu.success(`已跳转至${val}页面`)
+    },
+    [id]
+  )
+
+  // 查看模式下的按钮
+  const lookBtn = useMemo(() => {
+    return (
+      <>
+        {btnFlagFu2(topInfo)['创建'] ? (
+          <Button type='primary' onClick={() => lookBtnFu('创建')}>
+            创建
+          </Button>
+        ) : null}
+        {btnFlagFu2(topInfo)['提交'] ? (
+          <Button type='primary' onClick={() => lookBtnFu('提交')}>
+            提交
+          </Button>
+        ) : null}
+
+        {btnFlagFu2(topInfo)['撤回'] ? (
+          <MyPopconfirm
+            txtK='撤回'
+            onConfirm={() => lookBtnFu('撤回')}
+            Dom={
+              <Button type='primary' danger>
+                撤回
+              </Button>
+            }
+          />
+        ) : null}
+
+        {btnFlagFu2(topInfo)['审批'] ? (
+          <Button type='primary' onClick={() => lookJumpFu('审批')}>
+            审批
+          </Button>
+        ) : null}
+        {btnFlagFu2(topInfo)['编辑'] ? (
+          <Button type='primary' onClick={() => lookJumpFu('编辑')}>
+            编辑
+          </Button>
+        ) : null}
+
+        {btnFlagFu2(topInfo)['重新提交'] ? (
+          <Button type='primary' onClick={() => lookBtnFu('提交')}>
+            重新提交
+          </Button>
+        ) : null}
+
+        {EXbtnFu(topInfo)}
+
+        {btnFlagFu2(topInfo)['删除'] ? (
+          <MyPopconfirm
+            txtK='删除'
+            onConfirm={() => delFu()}
+            Dom={
+              <Button type='primary' danger>
+                删除
+              </Button>
+            }
+          />
+        ) : null}
+
+        <Button onClick={() => history.push('/accident')}>返回</Button>
+      </>
+    )
+  }, [delFu, lookBtnFu, lookJumpFu, topInfo])
+
+  // 申请记录
+  const [auditsShow, setAuditsShow] = useState(false)
+
+  return (
+    <div className={styles.E1edit}>
+      <div className='pageTitle'>事故登记-{pageTitTxt}</div>
+
+      <div className='E1main' ref={sollrDom}>
+        {['3'].includes(key) ? (
+          <X3auditInfo
+            dirCode='E1accident'
+            myUrl='cms/orderPreserveAccident/upload'
+            auditSta={auditSta}
+            auditStaFu={val => setAuDitSta(val)}
+            ref={ZAuditRef}
+          />
+        ) : null}
+
+        {/* 表单字段、附件等 */}
+        <div className='E1Tit'>
+          申请信息
+          {key === '1' ? null : (
+            <Button type='dashed'>{Reflect.get(statusObj, topInfo.status)}</Button>
+          )}
+        </div>
+
+        <div className='E1rowAll'>
+          <div className='E1row'>
+            <div className='E1rowll'>申请类型:</div>
+            <div className='E1rowrr'>{topInfo.name}</div>
+          </div>
+
+          <div className='E1row'>
+            <div className='E1rowll'>
+              <span> * </span>事故时间:
+            </div>
+            <div className='E1rowrr'>
+              <DatePicker
+                disabled={['3', '4'].includes(key)}
+                allowClear={false}
+                value={topInfo.date ? dayjs(topInfo.date) : null}
+                onChange={timeChange}
+              />
+            </div>
+          </div>
+
+          <div className='E1row'>
+            <div className='E1rowll'>
+              <span> * </span>事故责任:
+            </div>
+            <div className='E1rowrr'>
+              <Input
+                value={topInfo.sonTypeName}
+                onChange={e => setTopInfo({ ...topInfo, sonTypeName: e.target.value.trim() })}
+                readOnly={['3', '4'].includes(key)}
+                placeholder='请输入内容'
+                maxLength={30}
+                showCount
+              />
+            </div>
+          </div>
+
+          <div className='E1row'>
+            <div className='E1rowll'>
+              <span> * </span>事故藏品:
+            </div>
+            <div className='E1rowrr'>
+              <Select
+                disabled={['3', '4'].includes(key)}
+                allowClear={false}
+                placeholder='请选择编号类型'
+                style={{ width: 150 }}
+                value={topInfo.numName ? topInfo.numName : null}
+                onChange={e => {
+                  setTopInfo({ ...topInfo, numName: e, goodsIds: '' })
+                  numNameChangeFu(e)
+                }}
+                options={selectObj['藏品编号类型']}
+              />
+              <Select
+                disabled={['3', '4'].includes(key) || !topInfo.numName}
+                placeholder={!topInfo.numName ? '请先选择编号类型' : '请输入藏品编号或藏品名称'}
+                showSearch
+                filterOption={(input, option) => {
+                  const txt = option!.label + option!.num
+
+                  return txt.toLowerCase().includes(input.toLowerCase())
+                }}
+                options={goodsArr}
+                // fieldNames={{ label: 'num', value: 'num' }}
+                allowClear={false}
+                value={topInfo.goodsIds || null}
+                onChange={e => setTopInfo({ ...topInfo, goodsIds: e ? e : '' })}
+              />
+            </div>
+          </div>
+          <div className='E1row E1rowFull'>
+            <div className='E1rowll'>
+              事故前&emsp;
+              <br />
+              藏品状态:
+            </div>
+            <div className='E1rowrr'>
+              <ZRichTexts
+                check={false}
+                dirCode='E1accident'
+                myUrl='cms/orderPreserveAccident/upload'
+                isLook={['3', '4'].includes(key)}
+                ref={ZRichTextRefQian}
+                isOne={true}
+                upAudioBtnNone={true}
+              />
+            </div>
+          </div>
+
+          <div className='E1row E1rowFull'>
+            <div className='E1rowll'>
+              事故后&emsp;
+              <br />
+              藏品现状:
+            </div>
+            <div className='E1rowrr'>
+              <ZRichTexts
+                check={false}
+                dirCode='E1accident'
+                myUrl='cms/orderPreserveAccident/upload'
+                isLook={['3', '4'].includes(key)}
+                ref={ZRichTextRefHou}
+                isOne={true}
+                upAudioBtnNone={true}
+              />
+            </div>
+          </div>
+
+          <div className='E1row E1rowFull'>
+            <div className='E1rowll'>
+              事故原因&emsp;
+              <br />
+              及经过:
+            </div>
+            <div className='E1rowrr'>
+              <ZRichTexts
+                check={false}
+                dirCode='E1accident'
+                myUrl='cms/orderPreserveAccident/upload'
+                isLook={['3', '4'].includes(key)}
+                ref={ZRichTextRefYuan}
+                isOne={true}
+                upAudioBtnNone={true}
+              />
+            </div>
+          </div>
+
+          <div className='E1row E1row2'>
+            <div className='E1rowll'>附件:</div>
+            <div className='E1rowrr'>
+              <Z3upFiles
+                max={10}
+                isLook={['3', '4'].includes(key)}
+                ref={filesRef}
+                fileCheck={false}
+                dirCode='E1accident'
+                myUrl='cms/orderPreserveAccident/upload'
+                lookData={topInfo.files || []}
+                size={500}
+                fromData={{ moduleId: topInfo.id }}
+              />
+            </div>
+          </div>
+
+          <div className='E1row'>
+            <div className='E1rowll'>鉴定人:</div>
+            <div className='E1rowrr'>
+              <Input
+                value={topInfo.authUser}
+                onChange={e => setTopInfo({ ...topInfo, authUser: e.target.value.trim() })}
+                readOnly={['3', '4'].includes(key)}
+                placeholder='请输入内容'
+                maxLength={30}
+                showCount
+              />
+            </div>
+          </div>
+
+          <div className='E1row E1rowFull'>
+            <div className='E1rowll'>备注:</div>
+            <div className='E1rowrr'>
+              <ZRichTexts
+                check={false}
+                dirCode='E1accident'
+                myUrl='cms/orderPreserveAccident/upload'
+                isLook={['3', '4'].includes(key)}
+                ref={ZRichTextRef}
+                isOne={true}
+                upAudioBtnNone={true}
+              />
+            </div>
+          </div>
+        </div>
+
+        {/* 申请流程 */}
+        {auditsShow ? (
+          <B3flowTable tableArr={topInfo.audits || []} closeFu={() => setAuditsShow(false)} />
+        ) : null}
+      </div>
+
+      {/* 底部按钮 */}
+      <div className='E1btn'>
+        {['3', '4'].includes(key) && topInfo.audits && topInfo.audits.length ? (
+          <Button type='primary' onClick={() => setAuditsShow(true)}>
+            申请记录
+          </Button>
+        ) : null}
+
+        {key === '4' ? (
+          lookBtn
+        ) : (
+          <>
+            {key === '3' ? (
+              <Button type='primary' onClick={() => btnClickFu('审批')}>
+                审批
+              </Button>
+            ) : (
+              <Button type='primary' onClick={() => btnClickFu(key === '1' ? '创建' : '保存')}>
+                {key === '1' ? '创建' : '保存'}
+              </Button>
+            )}
+
+            {key === '1' ? (
+              <Button type='primary' onClick={() => btnClickFu('草稿')}>
+                存草稿
+              </Button>
+            ) : null}
+
+            <MyPopconfirm txtK='取消' onConfirm={() => history.push('/accident')} />
+          </>
+        )}
+      </div>
+    </div>
+  )
+}
+
+const MemoE1edit = React.memo(E1edit)
+
+export default MemoE1edit

+ 11 - 0
src/pages/E_goodsStorage/E1accident/data.ts

@@ -0,0 +1,11 @@
+import { E1InputKeyType } from './type'
+
+export const E1inputKeyArr: {
+  name: string
+  key: E1InputKeyType
+}[] = [
+  { name: '申请编号', key: 'num' },
+  { name: '藏品编号', key: 'goodsNum' },
+  { name: '藏品名称', key: 'goodsName' },
+  { name: '发起人', key: 'userName' }
+]

+ 5 - 0
src/pages/E_goodsStorage/E1accident/index.module.scss

@@ -23,6 +23,11 @@
         color: black;
       }
     }
+    .E1top0 {
+      .ant-input {
+        width: 148px !important;
+      }
+    }
     .ant-table-cell {
       padding: 8px !important;
     }

+ 302 - 2
src/pages/E_goodsStorage/E1accident/index.tsx

@@ -1,10 +1,310 @@
-import React from 'react'
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
 import styles from './index.module.scss'
+import { Button, DatePicker, Input, Select } from 'antd'
+import { E1FormType, E1InputKeyType } from './type'
+import { useDispatch, useSelector } from 'react-redux'
+import { E1_APIdel, E1_APIgetList } from '@/store/action/E1accident'
+import { MessageFu } from '@/utils/message'
+import history, { btnFlagFu } from '@/utils/history'
+import { FourTableType } from '@/pages/B_enterTibet/B3_4page/type'
+import MyPopconfirm from '@/components/MyPopconfirm'
+import { RootState } from '@/store'
+import dayjs from 'dayjs'
+import ExportJsonExcel from 'js-export-excel'
+import { E1inputKeyArr } from './data'
+import { selectObj } from '@/utils/select'
+import MyTable from '@/components/MyTable'
+import { E1tableC, statusObj } from '@/utils/tableData'
+const { RangePicker } = DatePicker
+
+const E1baseFormData: E1FormType = {
+  pageSize: 10,
+  pageNum: 1,
+  num: '',
+  dateStart: '',
+  dateEnd: '',
+  numName: '',
+  goodsNum: '',
+  goodsName: '',
+  userName: '',
+  userType: ''
+}
+
 function E1accident() {
+  const dispatch = useDispatch()
+
+  const [formData, setFormData] = useState(E1baseFormData)
+  const formDataRef = useRef(E1baseFormData)
+  const formDataOldRef = useRef(E1baseFormData)
+
+  useEffect(() => {
+    formDataRef.current = formData
+  }, [formData])
+
+  // 点击搜索的 时间戳
+  const [timeKey, setTimeKey] = useState(0)
+
+  // 点击搜索
+  const clickSearch = useCallback(() => {
+    setFormData({ ...formData, pageNum: 1 })
+    setTimeout(() => {
+      setTimeKey(Date.now())
+    }, 50)
+  }, [formData])
+
+  // 时间选择器改变
+  const timeChange = useCallback(
+    (date: any, dateString: any) => {
+      let dateStart = ''
+      let dateEnd = ''
+      if (dateString[0] && dateString[1]) {
+        dateStart = dateString[0] + ' 00:00:00'
+        dateEnd = dateString[1] + ' 23:59:59'
+      }
+      setFormData({ ...formData, dateStart, dateEnd })
+    },
+    [formData]
+  )
+
+  // 封装发送请求的函数
+  const getListFu = useCallback(() => {
+    formDataOldRef.current = { ...formDataRef.current }
+    dispatch(E1_APIgetList(formDataRef.current))
+  }, [dispatch])
+
+  useEffect(() => {
+    getListFu()
+  }, [getListFu, timeKey])
+
+  // 输入框的改变
+  const txtChangeFu = useCallback(
+    (txt: string, key: E1InputKeyType) => {
+      setFormData({
+        ...formData,
+        [key]: txt
+      })
+    },
+    [formData]
+  )
+
+  // 点击重置
+  const resetSelectFu = useCallback(() => {
+    setFormData(E1baseFormData)
+    setTimeout(() => {
+      setTimeKey(Date.now())
+    }, 50)
+  }, [])
+
+  // 页码变化
+  const paginationChange = useCallback(
+    (pageNum: number, pageSize: number) => {
+      setFormData({ ...formData, pageNum, pageSize })
+      setTimeout(() => {
+        setTimeKey(Date.now())
+      }, 50)
+    },
+    [formData]
+  )
+
+  // 点击删除
+  const delTableFu = useCallback(
+    async (id: number) => {
+      const res = await E1_APIdel(id)
+      if (res.code === 0) {
+        MessageFu.success('删除成功')
+        getListFu()
+      }
+    },
+    [getListFu]
+  )
+
+  // 点击操作按钮
+  const tableBtnFu = useCallback((id: number, key: string) => {
+    history.push(`/accident_edit/${key}/${id}`)
+  }, [])
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '操作',
+        render: (item: FourTableType) => {
+          let obj = btnFlagFu(item)
+          return !Object.values(obj).some(Boolean) ? (
+            '-'
+          ) : (
+            <>
+              {obj['编辑'] ? (
+                <Button size='small' type='text' onClick={() => tableBtnFu(item.id, '2')}>
+                  编辑
+                </Button>
+              ) : null}
+
+              {obj['审批'] ? (
+                <Button size='small' type='text' onClick={() => tableBtnFu(item.id, '3')}>
+                  审批
+                </Button>
+              ) : null}
+              {obj['查看'] ? (
+                <Button size='small' type='text' onClick={() => tableBtnFu(item.id, '4')}>
+                  查看
+                </Button>
+              ) : null}
+
+              {obj['删除'] ? (
+                <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
+              ) : null}
+            </>
+          )
+        }
+      }
+    ]
+  }, [delTableFu, tableBtnFu])
+
+  // 从仓库拿数据
+  const tableInfo = useSelector((state: RootState) => state.E1accident.tableInfo)
+
+  // 点击导出
+  const deriveFu = useCallback(async () => {
+    const name = '事故登记' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
+
+    const res = await E1_APIgetList(
+      {
+        ...formDataOldRef.current,
+        pageNum: 1,
+        pageSize: 99999
+      },
+      true
+    )
+
+    if (res.code === 0) {
+      if (res.data.records.length <= 0) return MessageFu.warning('当前搜索条件没有数据!')
+
+      const option = {
+        fileName: name,
+        datas: [
+          {
+            sheetData: res.data.records.map((v: FourTableType) => ({
+              ...v,
+              status: statusObj[v.status as 1]
+            })),
+            sheetName: name,
+            sheetFilter: [
+              'num',
+              'date',
+              'sonTypeName',
+              'numName',
+              'goodsNum',
+              'goodsName',
+              'authUser',
+              'creatorName',
+              'createTime',
+              'status'
+            ],
+            sheetHeader: [
+              '申请编号',
+              '事故时间',
+              '事故责任',
+              '编号类型',
+              '藏品编号',
+              '藏品名称',
+              '鉴定人',
+              '发起人',
+              '发送日期',
+              '申请状态'
+            ],
+            columnWidths: [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]
+          }
+        ]
+      }
+
+      const toExcel = new ExportJsonExcel(option) //new
+      toExcel.saveExcel() //保存
+    }
+  }, [])
+
   return (
     <div className={styles.E1accident}>
       <div className='pageTitle'>事故登记</div>
-      <p>待开发</p>
+      <div className='E1top'>
+        <div className='E1topll'>
+          {E1inputKeyArr.map(item => (
+            <div key={item.name}>
+              <span>{item.name}:</span>
+              <Input
+                placeholder={`请输入${item.name}`}
+                maxLength={30}
+                value={formData[item.key]}
+                onChange={e => txtChangeFu(e.target.value, item.key)}
+              />
+            </div>
+          ))}
+        </div>
+        <div className='E1toprr'>
+          <Button type='primary' onClick={deriveFu}>
+            批量导出
+          </Button>
+          &emsp;
+          <Button type='primary' onClick={() => history.push('/accident_edit/1/null')}>
+            新增
+          </Button>
+        </div>
+      </div>
+
+      <div className='E1top'>
+        <div className='E1topll'>
+          <div>
+            <span>事故日期范围:</span>
+            <RangePicker
+              value={
+                formData.dateStart ? [dayjs(formData.dateStart), dayjs(formData.dateEnd)] : null
+              }
+              onChange={timeChange}
+            />
+          </div>
+
+          <div>
+            <span>编号类型:</span>
+            <Select
+              allowClear={true}
+              placeholder='全部'
+              style={{ width: 150 }}
+              value={formData.numName ? formData.numName : null}
+              onChange={e => setFormData({ ...formData, numName: e })}
+              options={selectObj['藏品编号类型']}
+            />
+          </div>
+
+          <div>
+            <span>选择角色:</span>
+            <Select
+              allowClear={true}
+              style={{ width: 150 }}
+              placeholder='全部'
+              options={selectObj['角色']}
+              // fieldNames={{ value: 'id', label: 'roleName' }}
+              value={formData.userType ? formData.userType : null}
+              onChange={e => setFormData({ ...formData, userType: e })}
+            />
+          </div>
+        </div>
+        <div className='E1toprr'>
+          <Button type='primary' onClick={clickSearch}>
+            查询
+          </Button>
+          &emsp;<Button onClick={resetSelectFu}>重置</Button>
+        </div>
+      </div>
+      {/* 表格 */}
+      <MyTable
+        yHeight={610}
+        list={tableInfo.list}
+        columnsTemp={E1tableC}
+        lastBtn={tableLastBtn}
+        pageNum={formData.pageNum}
+        pageSize={formData.pageSize}
+        total={tableInfo.total}
+        onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
+      />
     </div>
   )
 }

+ 14 - 0
src/pages/E_goodsStorage/E1accident/type.d.ts

@@ -0,0 +1,14 @@
+export type E1FormType = {
+  pageSize: number
+  pageNum: number
+  num: string
+  dateStart: string
+  dateEnd: string
+  numName: string
+  goodsNum: string
+  goodsName: string
+  userName: string
+  userType: string
+}
+
+export type E1InputKeyType = keyof E1FormType

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

@@ -397,6 +397,13 @@ export const routerSon: RouterTypeRow[] = [
     Com: React.lazy(() => import('../B_enterTibet/B1collect/B1edit'))
   },
 
+  // ------------事故登记------------------
+  {
+    id: 13,
+    name: '事故登记-新增/编辑/审批/查看',
+    path: '/accident_edit/:key/:id',
+    Com: React.lazy(() => import('../E_goodsStorage/E1accident/E1edit'))
+  },
   // ------------残损登记------------------
   {
     id: 11,

+ 85 - 0
src/store/action/E1accident.ts

@@ -0,0 +1,85 @@
+import http from '@/utils/http'
+import { AppDispatch } from '..'
+/**
+ * 事故登记 - 获取分页列表
+ */
+export const E1_APIgetList = (data: any, exportFlag?: boolean): any => {
+  if (exportFlag) return http.post('cms/orderPreserveAccident/page', data)
+  else {
+    return async (dispatch: AppDispatch) => {
+      const res = await http.post('cms/orderPreserveAccident/page', data)
+      if (res.code === 0) {
+        const obj = {
+          list: res.data.records,
+          total: res.data.total
+        }
+
+        dispatch({ type: 'E1/getList', payload: obj })
+      }
+    }
+  }
+}
+
+/**
+ * 事故登记-删除
+ */
+export const E1_APIdel = (id: number) => {
+  return http.get(`cms/orderPreserveAccident/remove/${id}`)
+}
+
+/**
+ * 事故登记-创建订单
+ */
+export const E1_APIcreate = () => {
+  return http.get('cms/orderPreserveAccident/create')
+}
+
+/**
+ * 事故登记-获取详情
+ */
+export const E1_APIgetInfo = (id: number) => {
+  return http.get(`cms/orderPreserveAccident/detail/${id}`)
+}
+
+/**
+ * 事故登记-存草稿
+ */
+export const E1_APIsaveDraft = (data: any) => {
+  return http.post('cms/orderPreserveAccident/saveDraft', data)
+}
+
+/**
+ * 事故登记-创建
+ */
+export const E1_APIsaveCreate = (data: any) => {
+  return http.post('cms/orderPreserveAccident/saveCreate', data)
+}
+
+/**
+ * 事故登记-编辑保存
+ */
+export const E1_APIsaveApply = (data: any) => {
+  return http.post('cms/orderPreserveAccident/saveApply', data)
+}
+
+/**
+ * 事故登记-审批
+ */
+export const E1_APIsaveAudit = (data: any) => {
+  return http.post('cms/orderPreserveAccident/audit', data)
+}
+
+/**
+ * 事故登记-撤回订单
+ */
+export const E1_APIrevocation = (id: number) => {
+  return http.get(`cms/orderPreserveAccident/revocation/${id}`)
+}
+
+/**
+ * 事故登记-通过事故藏品编号获取藏品列表-下拉框使用
+ */
+export const E1_APIgetGoodsList = (typeName: string) => {
+  const data = { typeName }
+  return http.post('cms/orderPreserveAccident/goods/getList', data)
+}

+ 28 - 0
src/store/reducer/E1accident.ts

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

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

@@ -14,6 +14,7 @@ import C8recycleBin from './C8recycleBin'
 import D2storSet from './D2storSet'
 import D4impStor from './D4impStor'
 import D6putsStor from './D6putsStor'
+import E1accident from './E1accident'
 import E2damaged from './E2damaged'
 import E3actuality from './E3actuality'
 import Z1dict from './Z1dict'
@@ -38,6 +39,7 @@ const rootReducer = combineReducers({
   D2storSet,
   D4impStor,
   D6putsStor,
+  E1accident,
   E2damaged,
   E3actuality,
   Z1dict,

+ 13 - 0
src/utils/tableData.ts

@@ -171,6 +171,19 @@ export const D4goodsTableC = [
   ['txtChange', '库存状态', 'statusStorage', statusStorageObj]
 ]
 
+export const E1tableC = [
+  ['txt', '申请编号', 'num'],
+  ['txt', '事故时间', 'date'],
+  ['txt', '事故责任', 'sonTypeName'],
+  ['txt', '编号类型', 'numName'],
+  ['txt', '藏品编号', 'goodsNum'],
+  ['txt', '藏品名称', 'goodsName'],
+  ['txt', '鉴定人', 'authUser'],
+  ['txt', '发起人', 'creatorName'],
+  ['txt', '发送日期', 'createTime'],
+  ['txtChange', '申请状态', 'status', statusObj]
+]
+
 export const E2tableC = [
   ['txt', '业务单号', 'num'],
   ['txt', '申请名称', 'name'],