shaogen1995 3 дней назад
Родитель
Сommit
794a9ab3c9

+ 46 - 29
src/pages/Gmaintain/G1accident/G1edit/index.tsx

@@ -1,11 +1,11 @@
-import React from 'react'
+import React, { useEffect, useState } 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'
+import { getPanDianListFu } from '../data'
 import FileArchive from '@/pages/Zother/FileArchive'
 
 const rowArr = [
@@ -17,34 +17,51 @@ const rowArr = [
 ]
 
 function G1edit() {
+  const [info, setInfo] = useState<any>({ list: [], loding: false })
+
+  useEffect(() => {
+    getPanDianListFu(list => {
+      setInfo({ list, loding: true })
+    })
+  }, [])
+
   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'
-            }}
-          />
-
-          {/* 附件归档 */}
-          <FileArchive />
-
-          {/* 底部按钮 */}
-          <EditBtn path='/accident' APIobj={G1API_obj} checkListTxt='请选择关联藏品' isTow={true} />
-        </div>
-      </div>
-    </InfoProvider>
+    <>
+      {info.loding ? (
+        <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: info.list,
+                  myUrl: 'cms/orderAccident/son/upload',
+                  dirCode: 'accidentSon'
+                }}
+              />
+
+              {/* 附件归档 */}
+              <FileArchive />
+
+              {/* 底部按钮 */}
+              <EditBtn
+                path='/accident'
+                APIobj={G1API_obj}
+                checkListTxt='请选择关联藏品'
+                isTow={true}
+              />
+            </div>
+          </div>
+        </InfoProvider>
+      ) : null}
+    </>
   )
 }
 

+ 44 - 53
src/pages/Gmaintain/G1accident/data.ts

@@ -1,62 +1,53 @@
-// 获取盘点单列表
-let panDianList: any = []
+import { F4_APIgetList } from '@/store/action/Fstorehouse/F4check'
 
-const getPanDianListFu = () => {
-  console.log('xxxxx')
-  panDianList = [
+export const getPanDianListFu = async (back: (list: any[]) => void) => {
+  // 获取盘点单列表
+  const res = await F4_APIgetList({}, true)
+  if (res.code === 0) {
+    let list = res.data.records || []
+    list = list.map((v: any) => ({ value: v.num, label: `${v.num} - ${v.storageName}` }))
+    const listRes: any[] = G1moreList(list)
+    back(listRes)
+  }
+}
+export const G1moreList = (list: any[]) => {
+  return [
+    {
+      name: '关联盘点',
+      type: 'Select',
+      key: 'oderNum',
+      placeholder: '请搜索盘点申请编号',
+      options: list
+    },
+    {
+      name: '责任人',
+      type: 'Input',
+      key: 'userName'
+    },
     {
-      value: 'jack',
-      label: 'Jack'
+      name: '事故经过',
+      type: 'TextArea',
+      key: 'process',
+      full: true
+    },
+
+    {
+      name: '事故前&emsp;<br/>藏品状态',
+      type: 'TextArea',
+      key: 'beforeInfo',
+      full: true
     },
     {
-      value: 'lucy',
-      label: 'Lucy'
+      name: '事故后&emsp;<br/>藏品状态',
+      type: 'TextArea',
+      key: 'afterInfo',
+      full: true
     },
     {
-      value: 'tom',
-      label: 'Tom'
+      name: '备注',
+      type: 'TextArea',
+      key: 'remark',
+      full: true
     }
   ]
 }
-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
-  }
-]

+ 17 - 4
src/pages/Zother/EditTop/index.tsx

@@ -84,8 +84,23 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
     const res = await APIobj['创建订单']()
     if (res.code === 0) {
       setInfoFu(res.data)
+
+      // 从盘点过来---回显数据
+      const urlAll = window.location.href
+      if (urlAll.includes('?pNum=')) {
+        const txt = urlAll.split('?pNum=')[1]
+        const arr = txt.split(',')
+        const goodId = Number(arr[1])
+
+        const res2 = await API_getGoodsInfo(goodId)
+        if (res2.code === 0) {
+          setSnapsFu([{ ...res2.data, idTemp: res2.data.id }])
+          const obj: any = { oderNum: arr[0] }
+          setInfoFu(obj, true)
+        }
+      }
     }
-  }, [APIobj, setInfoFu])
+  }, [APIobj, setInfoFu, setSnapsFu])
 
   // 获取详情
   const getInfoFu = useCallback(
@@ -120,11 +135,9 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo, moreDom }: Props) {
 
           arrTemp.push(obj)
 
-          let obj2: any = {}
-          // 回显盘点
-
           // 第二个模块的信息回显
           if (moreDom && moreDom.domList && moreDom.domList.length && i === 0) {
+            let obj2: any = {}
             moreDom.domList.forEach((item: any) => {
               obj2[item.key] = obj[item.key]
             })