shaogen1995 недель назад: 2
Родитель
Сommit
31bf5e9618

+ 12 - 12
src/assets/styles/base.css

@@ -65,8 +65,6 @@ textarea {
   min-height: 900px;
   overflow: auto;
   overflow-y: overlay;
-  /* 普通文字按钮的颜色 */
-  /* 按钮的危险颜色 */
   /* antd分页器样式 */
   /* 表格的图片居中 */
   /* antd图片预览组件 */
@@ -91,16 +89,6 @@ textarea {
   font-size: 12px;
   border-radius: 50%;
 }
-#root .ant-btn-text {
-  color: #ab925b;
-}
-#root .ant-btn-text:disabled {
-  cursor: not-allowed;
-  color: rgba(0, 0, 0, 0.25);
-}
-#root .ant-btn-text.ant-btn-dangerous {
-  color: #ff4d4d;
-}
 #root .tableImgAuto {
   display: flex;
   justify-content: center;
@@ -191,3 +179,15 @@ textarea {
   height: calc(100% - 60px);
   overflow-y: auto;
 }
+/* 普通文字按钮的颜色 */
+.ant-btn-text {
+  color: #ab925b !important;
+}
+.ant-btn-text:disabled {
+  cursor: not-allowed !important;
+  color: rgba(0, 0, 0, 0.25) !important;
+}
+/* 按钮的危险颜色 */
+.ant-btn-text.ant-btn-dangerous {
+  color: #ff4d4d !important;
+}

+ 15 - 15
src/assets/styles/base.less

@@ -120,21 +120,6 @@ textarea {
   //   color: var(--themeColor);
   // }
 
-  /* 普通文字按钮的颜色 */
-  .ant-btn-text {
-    color: #ab925b;
-  }
-
-  .ant-btn-text:disabled {
-    cursor: not-allowed;
-    color: rgba(0, 0, 0, 0.25);
-  }
-
-  /* 按钮的危险颜色 */
-  .ant-btn-text.ant-btn-dangerous {
-    color: #ff4d4d;
-  }
-
   /* antd分页器样式 */
   // .ant-pagination .ant-pagination-item {
   //   border-radius: 50%;
@@ -325,3 +310,18 @@ textarea {
     overflow-y: auto;
   }
 }
+
+/* 普通文字按钮的颜色 */
+.ant-btn-text {
+  color: #ab925b !important;
+}
+
+.ant-btn-text:disabled {
+  cursor: not-allowed !important;
+  color: rgba(0, 0, 0, 0.25) !important;
+}
+
+/* 按钮的危险颜色 */
+.ant-btn-text.ant-btn-dangerous {
+  color: #ff4d4d !important;
+}

+ 53 - 29
src/pages/Zother/AddGoods/index.tsx

@@ -15,6 +15,7 @@ import { API_getGoodsInfo } from '@/store/action/Cledger/C1ledger'
 import { MessageFu } from '@/utils/message'
 import { API_getFileListByIds } from '@/store/action/Cledger/C4file'
 import { FileUpInfoType } from '../data'
+import { useInfo } from '../InfoContext'
 
 // 级联的数据转换成字符串
 export const cascaderChArr = [
@@ -49,6 +50,8 @@ type Props = {
 }
 
 function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo }: Props) {
+  const { delSnapIdsRef } = useInfo()
+
   // 获取标签 树结构
   const E1tree = useSelector((state: RootState) => state.E1tag.treeData)
 
@@ -64,41 +67,51 @@ function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo
   // 藏品编辑模块用来对比
   const objOld = useRef({} as GoodsType)
 
-  // 编辑进来获取详情
-  const getInfo = useCallback(async (id: number) => {
-    const res = await API_getGoodsInfo(id)
-    if (res.code === 0) {
-      // 藏品编辑信息保存
-      objOld.current = { ...res.data }
+  const resInfoFu = useCallback(async (infoRes: GoodsType) => {
+    // 藏品编辑信息保存
+    objOld.current = { ...infoRes }
 
-      const obj = { ...res.data }
-      // makeDate inGoodYear 2个日期需要格式处理一下
-      if (obj.makeDate) obj.makeDate = dayjs(obj.makeDate)
-      if (obj.inGoodYear) obj.inGoodYear = dayjs(obj.inGoodYear)
+    const obj: any = { ...infoRes }
+    // makeDate inGoodYear 2个日期需要格式处理一下
+    if (obj.makeDate) obj.makeDate = dayjs(obj.makeDate)
+    if (obj.inGoodYear) obj.inGoodYear = dayjs(obj.inGoodYear)
 
-      cascaderChArr.forEach(v => {
-        if (obj[v] === '0') obj[v] = null
-        else if (obj[v]) {
-          obj[v] = obj[v].split(',')
-        }
-      })
+    cascaderChArr.forEach(v => {
+      if (obj[v] === '0') obj[v] = null
+      else if (obj[v]) {
+        obj[v] = obj[v].split(',')
+      }
+    })
 
-      addZiSelectChArr.forEach(v => {
-        if (!obj[v]) obj[v] = null
-      })
+    addZiSelectChArr.forEach(v => {
+      if (!obj[v]) obj[v] = null
+    })
 
-      FormBoxRef.current?.setFieldsValue(obj)
+    FormBoxRef.current?.setFieldsValue(obj)
 
-      // 设置附件
-      if (obj.fileIds) {
-        const fileRes = await API_getFileListByIds(obj.fileIds.split(','))
-        if (fileRes.code === 0) {
-          fileRef.current?.sonSetListFu(fileRes.data || [])
-        }
+    // 设置附件
+    if (obj.fileIds) {
+      const fileRes = await API_getFileListByIds(obj.fileIds.split(','))
+      if (fileRes.code === 0) {
+        fileRef.current?.sonSetListFu(fileRes.data || [])
       }
     }
   }, [])
 
+  // 编辑进来获取详情
+  const getInfo = useCallback(
+    async (id: number) => {
+      if (info.pageType === 'clue') {
+        // 从征集进来 不用拿详情
+        resInfoFu(info)
+      } else {
+        const res = await API_getGoodsInfo(id)
+        if (res.code === 0) resInfoFu(res.data)
+      }
+    },
+    [info, resInfoFu]
+  )
+
   useEffect(() => {
     if (info.id > 0) getInfo(info.id)
   }, [getInfo, info.id])
@@ -121,7 +134,7 @@ function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo
 
       const obj = {
         ...values,
-        id: info.id > 0 ? info.id : null,
+        id: info.pageType === 'clue' ? null : info.id > 0 ? info.id : null,
         makeDate,
         inGoodYear,
         fileIds: flieList.map((v: any) => v.id).join(','),
@@ -145,11 +158,22 @@ function AddGoods({ closeFu, succFu, isEdit, moduleId, info, APIsave, fileUpInfo
       const res = await APIsave(obj)
       if (res.code === 0) {
         MessageFu.success(info.id > 0 ? '编辑成功' : '新增成功')
-        succFu(info.id > 0 ? '编辑' : '新增', res.data)
+        // if (1 + 1 === 2) {
+        //   console.log('----------------', info)
+        //   return
+        // }
+
+        const resObj = { ...res.data }
+        if (info.pageType === 'clue') {
+          resObj.clueId = info.id
+          if (info.id2) delSnapIdsRef.current.push(info.id2)
+        }
+
+        succFu(info.id > 0 ? '编辑' : '新增', resObj)
         closeFu()
       }
     },
-    [APIsave, closeFu, info.id, succFu]
+    [APIsave, closeFu, delSnapIdsRef, info, succFu]
   )
 
   return (

+ 63 - 23
src/pages/Zother/EditBtn/index.tsx

@@ -10,6 +10,7 @@ import { MessageFu } from '@/utils/message'
 import { fileIdsResFu } from '@/utils'
 import { API_objType } from '@/store/action/Dmanage/D1register'
 import AuditList from '../AuditList'
+import { GoodsType } from '../SonGoodsList/data'
 
 type Props = {
   path: string
@@ -42,6 +43,28 @@ function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
     }
   }, [btnCan])
 
+  // 藏品登记号为空 和重复的判断
+  const numFlag = (data: GoodsType[]) => {
+    const numSet = new Set<string>()
+
+    for (const item of data) {
+      // 检查是否为空
+      if (!item.num || item.num.trim() === '') {
+        return `${item.name} - 藏品登记号不能为空`
+      }
+
+      // 检查是否重复
+      if (numSet.has(item.num)) {
+        const duplicateNames = data.filter(d => d.num === item.num).map(d => d.name)
+        return `${duplicateNames.join(' / ')} - 藏品登记号重复`
+      }
+
+      numSet.add(item.num)
+    }
+
+    return null
+  }
+
   // 点击按钮触发事件
   const sonClick = useCallback(
     async (val: string, flag?: string) => {
@@ -49,23 +72,35 @@ function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
       // 新增、编辑、审批、查看互相跳转
       if (flag) pageSkitFu(path, val, info.id, flag)
       else {
-        const obj = {
-          ...info,
-          fileIds: fileIdsResFu(info.files),
-          goodIds: snaps
-            .filter(c => !c.isNew)
-            .map(v => v.id)
-            .join(','),
-          delSnapIds: delSnapIdsRef.current.length ? delSnapIdsRef.current : '',
-          snaps: snaps.map(v => ({
-            goodsId: v.isNew ? null : v.id,
+        const goodIdArr: number[] = []
+        const collectIdArr: number[] = []
+        const snapsArr: any[] = []
+
+        snaps.forEach(v => {
+          // 从征集中选的藏品--并且没有在点编辑(点提交)存到藏品数据库。这时候就属于征集id
+          const flag = v.pageType === 'clue' && !v.clueId
+
+          if (flag) collectIdArr.push(v.id)
+          else goodIdArr.push(v.id)
+
+          snapsArr.push({
+            goodsId: v.isNew || flag ? null : v.id,
             id: v.id2 ? v.id2 : null,
             orderId: info.id,
             snap: JSON.stringify({
               ...v,
-              id: v.isNew ? null : v.id
+              id: v.isNew || flag ? null : v.id
             })
-          }))
+          })
+        })
+
+        const obj = {
+          ...info,
+          fileIds: fileIdsResFu(info.files),
+          goodIds: goodIdArr.join(','),
+          collectIds: collectIdArr.join(','),
+          delSnapIds: delSnapIdsRef.current.length ? delSnapIdsRef.current : '',
+          snaps: snapsArr
         }
 
         // if (1 + 1 === 2) {
@@ -95,25 +130,30 @@ function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
             history.replace(path)
           }
         } else if (val === '发起') {
+          let txt = ''
+          if (isLook) txt = ',已为您跳转到编辑页面'
+
           if (!info.num) {
-            let txt = ''
-            if (key !== '2') {
-              txt = ',已为您跳转到编辑页面'
-              history.replace(`${path}_edit/2/${info.id}`)
-            }
+            if (isLook) history.replace(`${path}_edit/2/${info.id}`)
             MessageFu.warning('请输入申请编号' + txt)
 
             return
           }
           if (snaps.length === 0) {
-            let txt = ''
-            if (key !== '2') {
-              txt = ',已为您跳转到编辑页面'
-              history.replace(`${path}_edit/2/${info.id}`)
-            }
+            if (isLook) history.replace(`${path}_edit/2/${info.id}`)
 
             MessageFu.warning(`请至少添加一个${checkListTxt}${txt}`)
             return
+          } else if (path === '/register') {
+            // 校验藏品登记号 为空 或者 重复
+            // console.log('-----', snaps, obj)
+            const flag = numFlag(snaps)
+
+            if (flag) {
+              MessageFu.warning(flag + txt)
+              if (isLook) history.replace(`${path}_edit/2/${info.id}`)
+              return
+            }
           }
           const res = await APIobj['发起'](obj)
           if (res.code === 0) {
@@ -149,7 +189,7 @@ function EditBtn({ path, APIobj, checkListTxt = '藏品' }: Props) {
         }
       }
     },
-    [APIobj, auditInfo, checkListTxt, delSnapIdsRef, info, key, path, setTimeKeyFu, snaps]
+    [APIobj, auditInfo, checkListTxt, delSnapIdsRef, info, isLook, key, path, setTimeKeyFu, snaps]
   )
 
   // 申请记录的显示

+ 3 - 2
src/pages/Zother/EditTop/index.tsx

@@ -73,12 +73,13 @@ function EditTop({ rowArr, pageTxt, APIobj, fileUpInfo }: Props) {
 
           const obj = JSON.parse(v.snap || '{}')
 
-          if (obj.id === null && obj.isNew) obj.id = Date.now() + i
+          const flag = v.pageType === 'clue' && !v.clueId
+          if (obj.id === null || obj.isNew || flag) obj.id = Date.now() + i
 
           if (obj.id) obj.id2 = v.id
-
           arrTemp.push(obj)
         })
+        // console.log('-------', arrTemp)
 
         setSnapsFu(arrTemp)
       }

+ 7 - 0
src/pages/Zother/SelectGoods/index.module.scss

@@ -61,6 +61,13 @@
         top: 15px;
         text-align: center;
       }
+      .ant-checkbox-inner {
+        width: 30px;
+        height: 30px;
+      }
+      .ant-checkbox-inner:after {
+        left: 35%;
+      }
     }
   }
 }

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

@@ -212,7 +212,7 @@ function SelectGoods({
         {/* 表格 */}
         <MyTable
           yHeight={575}
-          classKey='ZGaddNow'
+          classKey='SelectGoods'
           list={tableList}
           columnsTemp={columnsTemp}
           staBtn={staBtn}

+ 5 - 1
src/pages/Zother/SonGoodsList/data.ts

@@ -59,6 +59,10 @@ export type GoodsType = {
 
   // 不用录数据库,新增和编辑 用这个区分
   isNew: boolean
+
+  // 区分是不是 征集数据-详情还没有入数据库
+  pageType?: 'clue'
+  clueId: number
 }
 
 // 藏品征集选择
@@ -87,7 +91,7 @@ export const sgTopSelectDom = [
     name: '初定年代',
     key: 'ageDictId',
     type: 'Cascader',
-    options: getDictFu('藏品类别')
+    options: getDictFu('藏品年代')
   },
   {
     name: '完残程度',

+ 20 - 2
src/pages/Zother/SonGoodsList/index.tsx

@@ -109,7 +109,7 @@ function SonGoodsList({ fileUpInfo }: Props) {
             } else {
               setSnapsFu(
                 snaps.map(v => {
-                  if (v.id === objTemp.id) return objTemp
+                  if (v.id === objTemp.id || v.id === objTemp.clueId) return objTemp
                   else return v
                 })
               )
@@ -127,7 +127,25 @@ function SonGoodsList({ fileUpInfo }: Props) {
           columnsTemp={goodsSelectCuleC}
           closeFu={() => setClueShow(false)}
           oldCheckArr={snaps}
-          dataResFu={data => {}}
+          dataResFu={data => {
+            //需要过滤掉已经有id的-不替换数据,没有id的替换数据 因为数据可能已经在另外一个弹窗更新了
+            const nowIds = snaps.map(v => v.id)
+            let dataRes = data.map((v, i) => {
+              if (nowIds.includes(v.id)) return snaps[i]
+              else return v
+            })
+
+            dataRes.forEach(v => {
+              v.pageType = 'clue'
+
+              // id2表示的是自己这条数据的id id才是goodsId
+              const obj = snapsID2ref.current.find(c => c.goodsId === v.id)
+
+              if (obj) v.id2 = obj.id
+            })
+
+            setSnapsFu(dataRes)
+          }}
         />
       ) : null}
     </div>