Browse Source

修复一波入库库房位置回显bug

shaogen1995 4 tháng trước cách đây
mục cha
commit
7b1e7d641b

+ 11 - 7
src/pages/B_enterTibet/B3goodsTable/B3GaddNew/index.tsx

@@ -104,10 +104,6 @@ function B3GaddNew({ nowSta, closeFu, succFu, isEdit }: Props) {
   useEffect(() => {
     if (nowSta.id !== 'null') {
       getInfo(Number(nowSta.id))
-    } else {
-      FormBoxRef.current?.setFieldsValue({
-        numName: '藏品总登记号'
-      })
     }
   }, [getInfo, nowSta.id])
 
@@ -355,11 +351,19 @@ function B3GaddNew({ nowSta, closeFu, succFu, isEdit }: Props) {
 
           <div className='B3Nbox'>
             <div className='B3Nrow B3Nrow0'>
-              <Form.Item label='藏品编号' name='numName' rules={[{ required: true, message: '' }]}>
-                <Select style={{ width: 140 }} options={selectObj['藏品编号类型']} />
+              <Form.Item
+                label='藏品编号'
+                name='numName'
+                rules={[{ required: true, message: '请选择编号类型' }]}
+              >
+                <Select
+                  style={{ width: 140 }}
+                  options={selectObj['藏品编号类型']}
+                  placeholder='请选择'
+                />
               </Form.Item>
 
-              <Form.Item name='num' rules={[{ required: true, message: '请输入内容' }]}>
+              <Form.Item name='num' rules={[{ required: true, message: '请输入藏品编号' }]}>
                 <Input maxLength={30} showCount placeholder='请输入内容' />
               </Form.Item>
             </div>

+ 1 - 1
src/pages/B_enterTibet/B3goodsTable/B3GaddNow/data.ts

@@ -19,7 +19,7 @@ export const B3nowArr2: B3nowSearchType = [
 export const B3baseFormData: B3nowFormType = {
   num: '',
   name: '',
-  numName: '藏品总登记号',
+  numName: '',
   dictLevel: '',
   dictType: '',
   dictAge: '',

+ 1 - 1
src/pages/C_goodsManage/C1ledger/data.ts

@@ -3,7 +3,7 @@ import { C1DomArrType, TYpeC1Form, TYpeC1Form1, TYpeC1Form2 } from './type'
 import { cascaderObjFu } from '@/utils/history'
 
 export const C1baseFormData1: TYpeC1Form1 = {
-  numName: '藏品总登记号',
+  numName: '',
   num: '',
   name: '',
   dictLevel: '',

+ 1 - 1
src/pages/C_goodsManage/C2files/data.ts

@@ -5,7 +5,7 @@ import { TypeZ1dict } from '@/pages/Z_system/Z1dict/type'
 import store from '@/store'
 
 export const C2baseFormData: TypeC2Form = {
-  goodNumName: '藏品总登记号',
+  goodNumName: '',
   goodNum: '',
   goodName: '',
   fileName: '',

+ 1 - 1
src/pages/D_storeManage/D1storage/D1goods/index.tsx

@@ -14,7 +14,7 @@ import { D1canType } from '../type'
 const baseFormData: TypeD1Gform = {
   pageSize: 10,
   pageNum: 1,
-  numName: '藏品总登记号',
+  numName: '',
   num: '',
   name: '',
   statusStorage: null

+ 2 - 4
src/pages/D_storeManage/D4impStor/D4edit/index.tsx

@@ -177,7 +177,7 @@ function D4edit() {
         if (!topInfo.goods || (topInfo.goods && topInfo.goods.length === 0)) {
           return MessageFu.warning('请添加藏品')
         } else {
-          if (topInfo.goods.some(v => !v.siteStr)) {
+          if (topInfo.goods.some(v => !v.siteStr || !v.siteId)) {
             return MessageFu.warning('请选择存放位置')
           }
         }
@@ -216,7 +216,6 @@ function D4edit() {
           goodsIds: topInfo.goods.map(v => v.id).join(','),
           goods: topInfo.goods.map(v => ({
             goodsId: v.id,
-            siteStr: v.siteStr,
             siteId: v.siteId
           }))
         }
@@ -277,7 +276,7 @@ function D4edit() {
               placeholder='请选择'
               // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
               allowClear={false}
-              value={item.siteStr ? item.siteStr.split(',').map(v => Number(v)) : undefined}
+              value={item.siteStr ? item.siteStr.split(',') : undefined}
               onChange={(e, e2) => {
                 let lastId: any = ''
                 if (e2 && e2.length === 4) lastId = e2[3].lastId
@@ -342,7 +341,6 @@ function D4edit() {
         goodsIds: topInfo.goods.map(v => v.id).join(','),
         goods: topInfo.goods.map(v => ({
           goodsId: v.id,
-          siteStr: v.siteStr,
           siteId: v.siteId
         }))
       }

+ 1 - 1
src/pages/D_storeManage/D4impStor/type.d.ts

@@ -14,7 +14,7 @@ export type TypeD4Form = {
 
 // 排架 层数 层格变成树的树结构
 export type KuIsTreeType = {
-  value: number
+  value: string
   label: string
   lastId?: number
   children?: KuIsTreeType[]

+ 4 - 42
src/pages/D_storeManage/D6putsStor/D6edit/index.tsx

@@ -8,12 +8,7 @@ import dayjs from 'dayjs'
 import Z3upFiles from '@/components/Z3upFiles'
 import ZRichTexts from '@/components/ZRichTexts'
 import { MessageFu } from '@/utils/message'
-import history, {
-  btnFlagFu2,
-  cascaderObjFu,
-  kuIsTreeChangeFu,
-  openGoodsInfoFu
-} from '@/utils/history'
+import history, { btnFlagFu2, cascaderObjFu, openGoodsInfoFu } from '@/utils/history'
 import B3GaddNow from '@/pages/B_enterTibet/B3goodsTable/B3GaddNow'
 import MyTable from '@/components/MyTable'
 import classNames from 'classnames'
@@ -36,11 +31,8 @@ import {
   D6_APIsaveCreate,
   D6_APIsaveDraft
 } from '@/store/action/D6putsStor'
-import { KuIsTreeType } from '../../D4impStor/type'
-import { D1_APIgetSiteList } from '@/store/action/D1storage'
 import { C1GoodType } from '@/pages/C_goodsManage/C1ledger/type'
 import { EXbtnFu } from '@/utils/EXBtn'
-import { TypeD2list } from '../../D2storSet/type'
 import D6impRelation from '../D6impRelation'
 
 function D6edit() {
@@ -80,17 +72,6 @@ function D6edit() {
     }
   }, [])
 
-  // 入库的排架 层数 层格变成树
-  const [kuIsTree, setKuIsTreeFu] = useState<KuIsTreeType[]>([])
-
-  const kuIsTreeFu = useCallback(async (id: number) => {
-    const res = await D1_APIgetSiteList(id, false)
-    if (res.code === 0) {
-      const arrTemp: KuIsTreeType[] = kuIsTreeChangeFu(res.data)
-      setKuIsTreeFu(arrTemp)
-    }
-  }, [])
-
   // 获取详情
   const getInfoFu = useCallback(async () => {
     const res = await D6_APIgetInfo(id)
@@ -99,11 +80,8 @@ function D6edit() {
 
       // 设置富文本
       ZRichTextRef.current?.ritxtShowFu(JSON.parse(res.data.rtf) || '{}')
-
-      // 出库库房筛选存放位置数据
-      if (res.data.storageId) kuIsTreeFu(res.data.storageId)
     }
-  }, [id, kuIsTreeFu])
+  }, [id])
 
   useEffect(() => {
     if (key === '1') creatFu()
@@ -161,10 +139,6 @@ function D6edit() {
       if (val !== '草稿') {
         if (!topInfo.goods || (topInfo.goods && topInfo.goods.length === 0)) {
           return MessageFu.warning('请添加藏品')
-        } else {
-          if (topInfo.goods.some(v => !v.siteStr)) {
-            return MessageFu.warning('请选择出库位置')
-          }
         }
       }
 
@@ -250,18 +224,7 @@ function D6edit() {
         title: '出库位置',
         width: 200,
         render: (item: C1GoodType) => {
-          return (
-            <Cascader
-              disabled
-              // disabled={['3', '4'].includes(key)}
-              options={kuIsTree}
-              placeholder='请选择'
-              // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
-              allowClear={false}
-              value={item.siteStr ? item.siteStr.split(',').map(v => Number(v)) : undefined}
-              onChange={() => {}}
-            />
-          )
+          return item.siteStr ? item.siteStr.replaceAll(',', ' / ') : '(空)'
         }
       },
       {
@@ -288,7 +251,7 @@ function D6edit() {
         }
       }
     ]
-  }, [key, kuIsTree, topInfo])
+  }, [key, topInfo])
 
   // 点击新增
   const [nowSta, setNowSta] = useState({ key: '', id: '' })
@@ -584,7 +547,6 @@ function D6edit() {
                 value={topInfo.storageId}
                 onChange={(storageId, arr) => {
                   setTopInfo({ ...topInfo, storageId, goods: [] })
-                  kuIsTreeFu((arr as TypeD2list).id)
                 }}
                 disabled={['3', '4'].includes(key)}
                 fieldNames={{ value: 'id', label: 'name' }}

+ 5 - 32
src/pages/E_goodsStorage/E2damaged/E2edit/index.tsx

@@ -14,14 +14,12 @@ import {
 } from '@/store/action/E2damaged'
 import { pageTitTxtObj } from '@/pages/D_storeManage/D4impStor/D4edit'
 import { MessageFu } from '@/utils/message'
-import history, { btnFlagFu2, kuIsTreeChangeFu, openGoodsInfoFu } from '@/utils/history'
+import history, { btnFlagFu2, openGoodsInfoFu } from '@/utils/history'
 import { C1GoodType } from '@/pages/C_goodsManage/C1ledger/type'
 import classNames from 'classnames'
 import dayjs from 'dayjs'
-import { Button, Cascader, DatePicker, Input, Select } from 'antd'
+import { Button, DatePicker, Input, Select } from 'antd'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { KuIsTreeType } from '@/pages/D_storeManage/D4impStor/type'
-import { D1_APIgetSiteList } from '@/store/action/D1storage'
 import B3GaddNow from '@/pages/B_enterTibet/B3goodsTable/B3GaddNow'
 import { EXbtnFu } from '@/utils/EXBtn'
 import X3auditInfo from '@/pages/X_stock/X3auditInfo'
@@ -51,17 +49,6 @@ function E2edit() {
     }
   }, [])
 
-  // 入库的排架 层数 层格变成树
-  const [kuIsTree, setKuIsTreeFu] = useState<KuIsTreeType[]>([])
-
-  const kuIsTreeFu = useCallback(async (id: number) => {
-    const res = await D1_APIgetSiteList(id, false)
-    if (res.code === 0) {
-      const arrTemp: KuIsTreeType[] = kuIsTreeChangeFu(res.data)
-      setKuIsTreeFu(arrTemp)
-    }
-  }, [])
-
   // 获取详情
   const getInfoFu = useCallback(async () => {
     const res = await E2_APIgetInfo(id)
@@ -70,11 +57,8 @@ function E2edit() {
 
       // 设置富文本
       ZRichTextRef.current?.ritxtShowFu(JSON.parse(res.data.rtf || '{}'))
-
-      // 入库库房筛选存放位置数据
-      if (res.data.storageId) kuIsTreeFu(res.data.storageId)
     }
-  }, [id, kuIsTreeFu])
+  }, [id])
 
   useEffect(() => {
     if (key === '1') creatFu()
@@ -197,17 +181,7 @@ function E2edit() {
         title: '存放位置',
         width: 200,
         render: (item: C1GoodType) => {
-          return (
-            <Cascader
-              disabled
-              options={kuIsTree}
-              placeholder='空'
-              // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
-              allowClear={false}
-              value={item.siteStr ? item.siteStr.split(',').map(v => Number(v)) : undefined}
-              onChange={() => {}}
-            />
-          )
+          return item.siteStr ? item.siteStr.replaceAll(',', ' / ') : '(空)'
         }
       },
       {
@@ -234,7 +208,7 @@ function E2edit() {
         }
       }
     ]
-  }, [key, kuIsTree, topInfo])
+  }, [key, topInfo])
 
   // 新增和从已关注的藏品中添加
   const [nowSta, setNowSta] = useState({ key: '', id: '' })
@@ -254,7 +228,6 @@ function E2edit() {
         goodsIds: (topInfo.goods || []).map(v => v.id).join(','),
         goods: topInfo.goods.map(v => ({
           goodsId: v.id,
-          siteStr: v.siteStr,
           siteId: v.siteId
         }))
       }

+ 1 - 1
src/pages/X_stock/X1setStoreLocS/index.tsx

@@ -32,7 +32,7 @@ function X1setStoreLocS({ closeFu, kuIsTree, succFu }: Props) {
           placeholder='请选择'
           // fieldNames={{ label: 'name', value: 'id', children: 'children' }}
           allowClear={false}
-          value={value ? value.split(',').map(v => Number(v)) : []}
+          value={value ? value.split(',') : []}
           onChange={(e, e2) => {
             if (e2 && e2.length === 4) lastId.current = e2[3].lastId
 

+ 1 - 2
src/pages/Y_goodsDetails/Y1cathet/Y22com.tsx

@@ -15,7 +15,7 @@ function Y22com({ isLook, info }: Props) {
   const getInfoFu = useCallback(async () => {
     if (info.siteId) {
       const res = await D1_APIgetInfo(info.siteId)
-      if (res.code === 0) setDetail(res.data)
+      if (res.code === 0) setDetail(res.data || {})
     }
   }, [info.siteId])
 
@@ -25,7 +25,6 @@ function Y22com({ isLook, info }: Props) {
 
   return (
     <div className='Y22com'>
-      {/* 待完善 */}
       <div className='Y22sta'>库存状态:{statusStorageObj[info.statusStorage] || '(空)'}</div>
 
       {/* 表格 */}

+ 11 - 10
src/utils/history.ts

@@ -272,7 +272,8 @@ export function kuIsTreeChangeFu(arr: any[]): KuIsTreeType[] {
     let regionNode = regionMap.get(item.regionId)
     if (!regionNode) {
       regionNode = {
-        value: item.id, // 注意:此处使用元素id作为value
+        // value: item.id, // 注意:此处使用元素id作为value
+        value: item.regionName,
         label: item.regionName,
         children: []
       }
@@ -284,7 +285,7 @@ export function kuIsTreeChangeFu(arr: any[]): KuIsTreeType[] {
     let layer1Node = layer1Map.get(layer1Key)
     if (!layer1Node) {
       layer1Node = {
-        value: item.layer1,
+        value: String(item.layer1),
         label: String(item.layer1),
         children: []
       }
@@ -320,19 +321,19 @@ export function kuIsTreeChangeFu(arr: any[]): KuIsTreeType[] {
 // 入库-自动分配空置库位
 export const ruTransformDataFu = (data: any[]): any[] => {
   // 用对象缓存区域基准ID
-  const regionBaseIdCache: Record<string, number> = {}
+  // const regionBaseIdCache: Record<string, number> = {}
 
-  // 先遍历建立区域-基准ID映射
-  data.forEach(item => {
-    if (!regionBaseIdCache[item.regionName]) {
-      regionBaseIdCache[item.regionName] = item.id
-    }
-  })
+  // // 先遍历建立区域-基准ID映射
+  // data.forEach(item => {
+  //   if (!regionBaseIdCache[item.regionName]) {
+  //     regionBaseIdCache[item.regionName] = item.id
+  //   }
+  // })
 
   // 转换数据结构
   return data.map(item => ({
     siteId: item.id,
-    siteStr: `${regionBaseIdCache[item.regionName]},${item.layer1},${item.layer2},${item.layer3}`
+    siteStr: `${item.regionName},${item.layer1},${item.layer2},${item.layer3}`
   }))
 }