shaogen1995 3 mēneši atpakaļ
vecāks
revīzija
fb8d46a2cc

+ 4 - 2
src/components/MyTable/index.tsx

@@ -25,6 +25,7 @@ type Props = {
   isNull?: string
   // 设置宽度
   widthSet?: any
+  rowKey?: string
 }
 
 function MyTable({
@@ -46,7 +47,8 @@ function MyTable({
   merge,
   myTitle,
   isNull = '(空)',
-  widthSet
+  widthSet,
+  rowKey = 'id'
 }: Props) {
   // 点击操作高亮
   const [clickAc, setClickAc] = useState(0)
@@ -184,7 +186,7 @@ function MyTable({
       scroll={{ y: yHeight ? yHeight : '' }}
       dataSource={list}
       columns={[...startBtn, ...columns, ...lastBtn]}
-      rowKey='id'
+      rowKey={rowKey}
       pagination={
         pagingInfo
           ? {

+ 2 - 0
src/pages/B_enterTibet/B3_4page/type.d.ts

@@ -28,6 +28,8 @@ export type FourTableType = {
   fileIds: string
   files: FileImgListType[]
   goods: C1GoodType[]
+  // 藏品编辑 对比
+  tempGoodsJson: C1GoodType
   goodsIds: string
   id: number
   name: string

+ 70 - 15
src/pages/B_enterTibet/B3goodsTable/B3GaddNew/index.tsx

@@ -51,20 +51,31 @@ const cascaderChArr = [
 type Props = {
   closeFu: () => void
   nowSta: { key: string; id: string }
-  isEdit: boolean
-  succFu: (obj: C1GoodType, type: '新增' | '编辑') => void
+  isEdit: boolean //藏品编辑模块
+  succFu: (
+    obj: C1GoodType,
+    type: '新增' | '编辑',
+    flieNew?: GoodFileType[],
+    fileOld?: GoodFileType[]
+  ) => void
 }
 
-function B3GaddNew({ nowSta, closeFu, succFu }: Props) {
+function B3GaddNew({ nowSta, closeFu, succFu, isEdit }: Props) {
   // 制档日期 / 制档人
   const [txtArr, setTxtArr] = useState([getTokenInfo().user.realName, dayjs().format('YYYY-MM-DD')])
 
+  // 藏品编辑模块用来对比
+  const objOld = useRef<any>({})
+
   // 编辑进来获取详情
   const getInfo = useCallback(async (id: number) => {
     const res = await API_goodsInfo(id)
     if (res.code === 0) {
+      // 藏品编辑信息保存
+      objOld.current = { ...res.data }
+
       // dateMaking inGoodsDate 2个日期需要格式处理一下
-      const obj = res.data
+      const obj = { ...res.data }
       if (obj.dateMaking) obj.dateMaking = dayjs(obj.dateMaking)
       if (obj.inGoodsDate) obj.inGoodsDate = dayjs(obj.inGoodsDate)
 
@@ -133,6 +144,21 @@ function B3GaddNew({ nowSta, closeFu, succFu }: Props) {
     [table]
   )
 
+  // 附件类型和附件用途是否禁用
+  const disabledSelect = useCallback(
+    (id: number) => {
+      let flag = false
+      if (isEdit) {
+        if (objOld.current && objOld.current.file && objOld.current.file.length) {
+          const oldFileIds: number[] = objOld.current.file.map((v: any) => v.id)
+          if (oldFileIds.includes(id)) flag = true
+        }
+      }
+      return flag
+    },
+    [isEdit]
+  )
+
   // 相关附件的操作
   const startBtn = useMemo(() => {
     return [
@@ -158,6 +184,7 @@ function B3GaddNew({ nowSta, closeFu, succFu }: Props) {
         title: '附件类型',
         render: (item: GoodFileType) => (
           <Select
+            disabled={disabledSelect(item.id)}
             style={{ width: 120 }}
             placeholder='请选择'
             value={item.type}
@@ -170,6 +197,7 @@ function B3GaddNew({ nowSta, closeFu, succFu }: Props) {
         title: '附件用途',
         render: (item: GoodFileType) => (
           <Cascader
+            disabled={disabledSelect(item.id)}
             options={cascaderObjFu()['附件用途']}
             value={item.effect ? item.effect.split(',') : []}
             onChange={e => tableFu('effect', item.id, e ? e.join(',') : '')}
@@ -179,7 +207,7 @@ function B3GaddNew({ nowSta, closeFu, succFu }: Props) {
         )
       }
     ]
-  }, [tableFu])
+  }, [disabledSelect, tableFu])
 
   const tableLastBtn = useMemo(() => {
     return [
@@ -216,11 +244,6 @@ function B3GaddNew({ nowSta, closeFu, succFu }: Props) {
   // 通过校验点击确定
   const onFinish = useCallback(
     async (values: any) => {
-      // 删除附件
-      if (fileDelIdArr.current.length) {
-        await API_C2dels(fileDelIdArr.current)
-      }
-
       // 封面图
       const coverUrl1 = ZupThumbRef.current?.fileComFileResFu()
 
@@ -266,14 +289,46 @@ function B3GaddNew({ nowSta, closeFu, succFu }: Props) {
         }
       })
 
-      const res = await API_goodsAdd(obj, nowSta.id === 'null' ? '新增' : '编辑')
-      if (res.code === 0) {
-        MessageFu.success(nowSta.id === 'null' ? '新增成功' : '编辑成功')
-        succFu(res.data, nowSta.id === 'null' ? '新增' : '编辑')
+      if (isEdit) {
+        let flag = true
+
+        // fileIds 要特别处理
+        const fileNew = table.map(v => v.id).join(',')
+        const fileOld = (objOld.current.file || []).map((v: any) => v.id).join(',')
+
+        if (fileNew !== fileOld) flag = true
+
+        for (const k in obj) {
+          if (!['fileIds', 'fileSet'].includes(k)) {
+            if (objOld.current[k] !== obj[k]) {
+              flag = false
+            }
+          }
+        }
+        // if (1 + 1 === 2) return
+
+        if (flag) return MessageFu.warning('未修改藏品信息')
+
+        // -----------藏品编辑模块进来---------------
+        MessageFu.success('编辑成功')
+        succFu(obj, '编辑', table || [], objOld.current.file || [])
         closeFu()
+      } else {
+        // -----------默认模块的新增和编辑-----------
+        // 删除附件
+        if (fileDelIdArr.current.length) {
+          await API_C2dels(fileDelIdArr.current)
+        }
+
+        const res = await API_goodsAdd(obj, nowSta.id === 'null' ? '新增' : '编辑')
+        if (res.code === 0) {
+          MessageFu.success(nowSta.id === 'null' ? '新增成功' : '编辑成功')
+          succFu(res.data, nowSta.id === 'null' ? '新增' : '编辑')
+          closeFu()
+        }
       }
     },
-    [closeFu, nowSta.id, succFu, table]
+    [closeFu, isEdit, nowSta.id, succFu, table]
   )
 
   return (

+ 2 - 2
src/pages/B_enterTibet/B3goodsTable/B3GaddNow/index.tsx

@@ -106,8 +106,8 @@ function B3GaddNow({ nowSta, closeFu, isOne = false, dataResFu, oldCheckArr, can
     (item: C1GoodType) => {
       // 藏品编辑只能单选
       if (isOne) {
-        // setCheckNum([item])
-        setCheckArr([item])
+        if (checkArr && checkArr.length && item.id === checkArr[0].id) setCheckArr([])
+        else setCheckArr([item])
       } else {
         if (checkArr.map(v => v.id).includes(item.id))
           setCheckArr(checkArr.filter(v => v.id !== item.id))

+ 419 - 182
src/pages/C_goodsManage/C6edit/C6add/index.tsx

@@ -10,9 +10,9 @@ import Z3upFiles from '@/components/Z3upFiles'
 import ZRichTexts from '@/components/ZRichTexts'
 import B3GaddNow from '@/pages/B_enterTibet/B3goodsTable/B3GaddNow'
 import MyTable from '@/components/MyTable'
-import history, { openGoodsInfoFu } from '@/utils/history'
+import history, { btnFlagFu2, openGoodsInfoFu, textFu } from '@/utils/history'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import { B3eTableC } from '@/utils/tableData'
+import { B3eTableC, statusObj } from '@/utils/tableData'
 import { MessageFu } from '@/utils/message'
 import classNames from 'classnames'
 import Y1cathet from '@/pages/Y_goodsDetails/Y1cathet'
@@ -20,18 +20,99 @@ import B3GaddNew from '@/pages/B_enterTibet/B3goodsTable/B3GaddNew'
 import ImageLazy from '@/components/ImageLazy'
 import X2lookText from '@/pages/X_stock/X2lookText'
 import B3flowTable from '@/pages/B_enterTibet/B3flowTable'
+import { FourTableType } from '@/pages/B_enterTibet/B3_4page/type'
+import {
+  C6_APIcreate,
+  C6_APIdel,
+  C6_APIgetInfo,
+  C6_APIrevocation,
+  C6_APIsaveApply,
+  C6_APIsaveAudit,
+  C6_APIsaveCreate,
+  C6_APIsaveDraft
+} from '@/store/action/C6edit'
+import { EXbtnFu } from '@/utils/EXBtn'
+import {
+  ArrKeyType,
+  Y11infoArr1,
+  Y11infoArr2,
+  Y11infoArr3,
+  Y11infoArr4,
+  Y11infoArr5
+} from '@/pages/Y_goodsDetails/Y1cathet/data'
+import { baseURL } from '@/utils/http'
+import { GoodFileType } from '@/pages/B_enterTibet/B3goodsTable/B3GaddNew/type'
+
+export type OldNewType = {
+  name: string
+  qian: string | GoodFileType[]
+  hou: string | GoodFileType[]
+}
+
+const oldNewTxtArr: ArrKeyType = [
+  ...Y11infoArr1,
+  ...Y11infoArr2,
+  ...Y11infoArr3,
+  ...Y11infoArr4,
+  ...Y11infoArr5,
+  {
+    name: '封面图',
+    key: 'thumb',
+    backFu: info => {
+      return { thumb: info.thumb, thumbPc: info.thumbPc }
+    }
+  }
+]
 
 function C6add() {
+  // 新旧附件信息对比
+  const [oldNewArr, setOldNewArr] = useState<OldNewType[]>([])
+
   const { key, id } = useParams<any>()
+  // key:1 新增 2编辑 3审批 4查看
 
   // 滚到顶部
   const sollrDom = useRef<HTMLDivElement>(null)
 
+  // 顶部数据
+  const [topInfo, setTopInfo] = useState({} as FourTableType)
+
+  // 创建订单
+  const creatFu = useCallback(async () => {
+    const res = await C6_APIcreate()
+    if (res.code === 0) {
+      setTopInfo(res.data)
+    }
+  }, [])
+
+  // 获取详情
+  const getInfoFu = useCallback(async () => {
+    const res = await C6_APIgetInfo(id)
+    if (res.code === 0) {
+      const obj = { ...res.data }
+
+      try {
+        if (obj.goods && obj.goods.length && obj.goods[0].tempGoodsJson)
+          obj.tempGoodsJson = JSON.parse(obj.goods[0].tempGoodsJson)
+
+        if (obj.snap) setOldNewArr(JSON.parse(obj.snap))
+      } catch (error) {
+        console.log('error:', error)
+      }
+
+      setTopInfo(obj)
+
+      // 设置富文本
+      ZRichTextRef.current?.ritxtShowFu(JSON.parse(res.data.rtf || '{}'))
+    }
+  }, [id])
+
   useEffect(() => {
-    console.log('key:', key)
+    if (key === '1') creatFu()
+    else getInfoFu()
 
     if (sollrDom.current) sollrDom.current.scrollTop = 0
-  }, [key])
+  }, [creatFu, getInfoFu, key])
 
   // 上传附件的ref
   const filesRef = useRef<any>(null)
@@ -43,43 +124,94 @@ function C6add() {
   // 审批意见的ref
   const ZAuditRef = useRef<any>(null)
 
-  // 设置富文本
-  //  ZRichTextRef.current?.ritxtShowFu(JSON.parse(data.rtf))
+  const timeChange = useCallback(
+    (e: any) => {
+      setTopInfo({ ...topInfo, date: dayjs(e).format('YYYY-MM-DD') })
+    },
+    [topInfo]
+  )
 
-  const timeChange = useCallback((e: any) => {
-    console.log(123, e)
-  }, [])
+  // 审批的sta
+  const [auditSta, setAuDitSta] = useState('')
 
   // 新增的底部按钮点击
-  const btnClickFu = useCallback((val: number) => {
-    const rtf1 = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
-    console.log('申请信息富文本', JSON.stringify(rtf1.val || ''))
+  const btnClickFu = useCallback(
+    async (val: '草稿' | '创建' | '保存' | '审批') => {
+      if (!topInfo.name) return MessageFu.warning('申请名称不能为空')
 
-    const rtf2 = ZAuditRef.current?.resData()
-    console.log('审批信息富文本', rtf2)
+      // 藏品编辑校验
+      if (val !== '草稿') {
+        if (!topInfo.goods || (topInfo.goods && topInfo.goods.length === 0))
+          return MessageFu.warning('请选择藏品')
 
-    // if (1 + 1 === 2) return
+        if (oldNewArr.length === 0) return MessageFu.warning('未修改藏品信息')
+      }
 
-    if (val === 2) {
-      // 存草稿 当前页保存 不跳转
-      MessageFu.success('草稿保存成功')
-    } else {
-      // 跳到详情页
-      history.push(`/edit_add/4/999`)
-    }
-  }, [])
+      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 C6_APIsaveAudit({
+          orderId: topInfo.id,
+          rtfOpinion: rtf2,
+          status: auditSta === '同意' ? 1 : 2
+        })
+
+        if (res.code === 0) {
+          MessageFu.success('审批成功')
+          // 跳详情页
+          history.push(`/edit_add/4/${topInfo.id}`)
+        }
+      } else {
+        const rtf1 = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
+        // console.log('申请信息富文本', JSON.stringify(rtf1.val || ''))
+
+        // 上传附件
+        const filesRes = filesRef.current.filesIdRes()
+
+        const obj = {
+          ...topInfo,
+          fileIds: filesRes.join(','),
+          rtf: JSON.stringify(rtf1.val || ''),
+          goodsIds: topInfo.goods.map(v => v.id).join(','),
+          snap: JSON.stringify(oldNewArr),
+          tempGoodsJson: topInfo.tempGoodsJson
+        }
+        // console.log(123, obj)
+
+        // if (1 + 1 === 2) return
+
+        if (val === '草稿') {
+          // 存草稿 当前页保存 不跳转
+          const res = await C6_APIsaveDraft(obj)
+          if (res.code === 0) {
+            MessageFu.success('草稿保存成功')
+          }
+        } else {
+          const res = val === '创建' ? await C6_APIsaveCreate(obj) : await C6_APIsaveApply(obj)
+          if (res.code === 0) {
+            MessageFu.success(`${val}成功`)
+            // 跳到详情页
+            history.push(`/edit_add/4/${topInfo.id}`)
+          }
+        }
+      }
+    },
+    [auditSta, oldNewArr, topInfo]
+  )
 
   // 打开侧边栏
   const [cathet, setCathet] = useState(0)
 
-  // 点击删除
-  const delTableFu = useCallback(async (id: number) => {}, [])
-
   const startBtn = useMemo(() => {
     return [
       {
         title: '藏品编号',
-        render: (item: any) => {
+        render: (item: FourTableType) => {
           return (
             <span
               onClick={() => setCathet(item.id)}
@@ -97,72 +229,186 @@ function C6add() {
     return [
       {
         title: '操作',
-        render: (item: any) => {
+        render: (item: FourTableType) => {
           return (
             <>
               <Button size='small' type='text' onClick={() => openGoodsInfoFu(item.id)}>
                 查看
               </Button>
               {['3', '4'].includes(key) ? null : (
-                <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
+                <MyPopconfirm
+                  txtK='删除'
+                  onConfirm={() =>
+                    setTopInfo({
+                      ...topInfo,
+                      goods: topInfo.goods.filter(v => v.id !== item.id)
+                    })
+                  }
+                />
               )}
             </>
           )
         }
       }
     ]
-  }, [delTableFu, key])
-
-  // 审批的sta
-  const [auditSta, setAuDitSta] = useState('')
+  }, [key, topInfo])
 
   // 点击所选藏品 / 继续编辑
   const [nowSta, setNowSta] = useState({ key: '', id: '', type: '' })
 
-  // 查看模式下的按钮 待完善
+  // 查看的按钮创建-提交-撤回
+  const lookBtnFu = useCallback(
+    async (val: '创建' | '提交' | '撤回') => {
+      const rtf1 = ZRichTextRef.current?.fatherBtnOkFu() || { flag: true }
+      // console.log('申请信息富文本', JSON.stringify(rtf1.val || ''))
+
+      // 上传附件
+      const filesRes = filesRef.current.filesIdRes()
+      const obj = {
+        ...topInfo,
+        fileIds: filesRes.join(','),
+        rtf: JSON.stringify(rtf1.val || ''),
+        goodsIds: topInfo.goods.map(v => v.id).join(','),
+        snap: JSON.stringify(oldNewArr),
+        tempGoodsJson: topInfo.tempGoodsJson
+      }
+
+      const res =
+        val === '创建'
+          ? await C6_APIsaveCreate(obj)
+          : val === '提交'
+          ? await C6_APIsaveApply(obj)
+          : await C6_APIrevocation(id)
+
+      if (res.code === 0) {
+        if (sollrDom.current) sollrDom.current.scrollTop = 0
+        MessageFu.success(val + '成功')
+        getInfoFu()
+      }
+    },
+    [getInfoFu, id, oldNewArr, topInfo]
+  )
+
+  // 查看模式点击删除
+  const delFu = useCallback(async () => {
+    const res = await C6_APIdel(id)
+    if (res.code === 0) {
+      MessageFu.success('删除成功')
+      history.push('/edit')
+    }
+  }, [id])
+
+  // 查看模式点击审批 编辑
+  const lookJumpFu = useCallback(
+    (val: '审批' | '编辑') => {
+      history.push(`/edit_add/${val === '审批' ? 3 : 2}/${id}`)
+      MessageFu.success(`已跳转至${val}页面`)
+    },
+    [id]
+  )
+
+  // 查看模式下的按钮
   const lookBtn = useMemo(() => {
     return (
       <>
-        <Button type='primary'>创建</Button>
-        <Button type='primary'>提交</Button>
-        <MyPopconfirm
-          txtK='撤回'
-          onConfirm={() => {}}
-          Dom={
-            <Button type='primary' danger>
-              撤回
-            </Button>
-          }
-        />
-
-        <Button type='primary'>审批</Button>
-        <Button type='primary'>编辑</Button>
-        <Button type='primary'>重新提交</Button>
-        <Button type='primary'>导出</Button>
-        <MyPopconfirm
-          txtK='删除'
-          onConfirm={() => {}}
-          Dom={
-            <Button type='primary' danger>
-              删除
-            </Button>
-          }
-        />
+        {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()}
+
+        {btnFlagFu2(topInfo)['删除'] ? (
+          <MyPopconfirm
+            txtK='删除'
+            onConfirm={() => delFu()}
+            Dom={
+              <Button type='primary' danger>
+                删除
+              </Button>
+            }
+          />
+        ) : null}
+
         <Button onClick={() => history.push('/edit')}>返回</Button>
       </>
     )
-  }, [])
-
-  // 模拟 所选藏品 表格数据
-  const [listTemp, setListTemp] = useState<any[]>([{ id: 99, thumb: '', num: '一段编号_可点击' }])
+  }, [delFu, lookBtnFu, lookJumpFu, topInfo])
 
   // 编辑明细 表格
+
+  const tableLastBtn2Fu = useCallback((item: OldNewType, key: 'qian' | 'hou') => {
+    if (item.name === '备注') {
+      if (textFu(item[key] as string)) {
+        return (
+          <Button size='small' type='text' onClick={() => setLook(textFu(item[key] as string))}>
+            查看
+          </Button>
+        )
+      } else return '-'
+    } else if (item.name === '附件信息') {
+      let arr = item[key] as GoodFileType[]
+
+      return arr.length
+        ? arr.map((v: any, i: number) => (
+            <a key={v.id} href={baseURL + v.filePath} download target='_blank' rel='noreferrer'>
+              {v.fileName}
+              {i < arr!.length - 1 ? ',' : ''}
+            </a>
+          ))
+        : '-'
+    } else if (item.name === '封面图') {
+      const info: any = item[key]
+
+      return (
+        <div className='tableImgAuto'>
+          <ImageLazy width={60} height={60} srcBig={info.thumbPc} src={info.thumb} />
+        </div>
+      )
+    } else return item[key] || '(空)'
+  }, [])
+
   const tableLastBtn2 = useMemo(() => {
     return [
       {
         title: '编辑项',
-        render: (item: any) =>
-          ['封面图', '附件信息', '简介'].includes(item.name) ? (
+        render: (item: OldNewType) =>
+          ['封面图', '附件信息', '备注'].includes(item.name) ? (
             <span className='C6tab2Tit'>{item.name}</span>
           ) : (
             item.name
@@ -170,62 +416,14 @@ function C6add() {
       },
       {
         title: '编辑前',
-        render: (item: any) => {
-          if (item.name === '封面图')
-            return (
-              <div className='tableImgAuto'>
-                <ImageLazy
-                  width={60}
-                  height={60}
-                  srcBig={item.qian}
-                  src={item.qian}
-                  offline={true}
-                />
-              </div>
-            )
-          else if (item.name === '附件信息')
-            return item.qian.map((v: any, i: number) => (
-              <a key={v.name} href={v.src} download target='_blank' rel='noreferrer'>
-                {v.name}
-                {i < item.qian.length - 1 ? ',' : ''}
-              </a>
-            ))
-          else if (item.name === '简介')
-            return (
-              <Button size='small' type='text' onClick={() => setLook('xxx')}>
-                查看
-              </Button>
-            )
-          else return item.qian || '(空)'
-        }
+        render: (item: OldNewType) => tableLastBtn2Fu(item, 'qian')
       },
       {
         title: '编辑后',
-        render: (item: any) => {
-          if (item.name === '封面图')
-            return (
-              <div className='tableImgAuto'>
-                <ImageLazy width={60} height={60} srcBig={item.hou} src={item.hou} offline={true} />
-              </div>
-            )
-          else if (item.name === '附件信息')
-            return item.hou.map((v: any, i: number) => (
-              <a key={v.name} href={v.src} download target='_blank' rel='noreferrer'>
-                {v.name}
-                {i < item.hou.length - 1 ? ',' : ''}
-              </a>
-            ))
-          else if (item.name === '简介')
-            return (
-              <Button size='small' type='text' onClick={() => setLook('xxx')}>
-                查看
-              </Button>
-            )
-          else return item.hou || '(空)'
-        }
+        render: (item: OldNewType) => tableLastBtn2Fu(item, 'hou')
       }
     ]
-  }, [])
+  }, [tableLastBtn2Fu])
 
   //查看富文本信息
   const [look, setLook] = useState('')
@@ -237,8 +435,8 @@ function C6add() {
       <div className='C6main' ref={sollrDom}>
         {['3'].includes(key) ? (
           <X3auditInfo
-            dirCode='待完善'
-            myUrl='待完善'
+            dirCode='C6edit'
+            myUrl='cms/orderEdit/upload'
             auditSta={auditSta}
             auditStaFu={val => setAuDitSta(val)}
             ref={ZAuditRef}
@@ -247,9 +445,10 @@ function C6add() {
 
         {/* 表单字段、附件等 */}
         <div className='C6Tit'>
-          {/* 待完善 */}
           申请信息
-          <Button type='dashed'>草稿</Button>
+          {key === '1' ? null : (
+            <Button type='dashed'>{Reflect.get(statusObj, topInfo.status)}</Button>
+          )}
         </div>
         <div className='C6rowAll'>
           <div className='C6row'>
@@ -258,6 +457,8 @@ function C6add() {
             </div>
             <div className='C6rowrr'>
               <Input
+                value={topInfo.name}
+                onChange={e => setTopInfo({ ...topInfo, name: e.target.value.trim() })}
                 readOnly={['3', '4'].includes(key)}
                 placeholder='请输入内容'
                 maxLength={30}
@@ -274,7 +475,7 @@ function C6add() {
               <DatePicker
                 disabled={['3', '4'].includes(key)}
                 allowClear={false}
-                value={dayjs()}
+                value={dayjs(topInfo.date)}
                 onChange={timeChange}
               />
             </div>
@@ -284,9 +485,9 @@ function C6add() {
             <div className='C6row' key={v.name}>
               <div className='C6rowll'>{v.name}:</div>
               <div className='C6rowrr'>
-                这是一段文本
+                {topInfo[v.key as 'name']}
                 {['3', '4'].includes(key) && v.name === '发起人'
-                  ? ' - 查看和审批后面显示创建时间'
+                  ? ' - ' + topInfo.createTime || ''
                   : ''}
               </div>
             </div>
@@ -300,9 +501,9 @@ function C6add() {
                 isLook={['3', '4'].includes(key)}
                 ref={filesRef}
                 fileCheck={false}
-                dirCode={'xxxxxxx'}
-                myUrl='xxxxxxxxxxxx'
-                lookData={[]}
+                dirCode='C6edit'
+                myUrl='cms/orderEdit/upload'
+                lookData={topInfo.files || []}
                 size={500}
               />
             </div>
@@ -312,6 +513,8 @@ function C6add() {
             <div className='C6rowll'>原因事由:</div>
             <div className='C6rowrr'>
               <Input
+                value={topInfo.reason}
+                onChange={e => setTopInfo({ ...topInfo, reason: e.target.value })}
                 readOnly={['3', '4'].includes(key)}
                 placeholder='请输入内容'
                 maxLength={30}
@@ -325,10 +528,10 @@ function C6add() {
             <div className='C6rowrr'>
               <ZRichTexts
                 check={false}
-                dirCode={'xxxxxxxx'}
+                dirCode='C6edit'
+                myUrl='cms/orderEdit/upload'
                 isLook={['3', '4'].includes(key)}
                 ref={ZRichTextRef}
-                myUrl='xxxxxxxxxx'
                 isOne={true}
                 upAudioBtnNone={true}
               />
@@ -343,13 +546,20 @@ function C6add() {
             <div className='C6Tit2rr'>
               {['3', '4'].includes(key) ? null : (
                 <>
-                  <Button type='primary' onClick={() => setNowSta({ key: '7', id, type: 'now' })}>
+                  <Button
+                    type='primary'
+                    onClick={() =>
+                      setNowSta({ key: '7', id: 'cms/orderEdit/goods/getList', type: 'now' })
+                    }
+                  >
                     选择藏品
                   </Button>
                   <Button
-                    disabled={listTemp.length === 0}
+                    disabled={!(topInfo.goods && topInfo.goods.length)}
                     type='primary'
-                    onClick={() => setNowSta({ key: '7', id, type: 'new' })}
+                    onClick={() =>
+                      setNowSta({ key: '7', id: topInfo.goods[0].id + '', type: 'new' })
+                    }
                   >
                     继续编辑
                   </Button>
@@ -360,7 +570,7 @@ function C6add() {
 
           {/* 表格 */}
           <MyTable
-            list={listTemp}
+            list={topInfo.goods || []}
             columnsTemp={B3eTableC}
             startBtn={startBtn}
             lastBtn={tableLastBtn}
@@ -374,36 +584,8 @@ function C6add() {
 
           {/* 表格 */}
           <MyTable
-            list={[
-              { id: 1, name: '名称', qian: '11', hou: '22' },
-              {
-                id: 2,
-                name: '封面图',
-                qian: 'https://houseoss.4dkankan.com/project/DEMO/staticResource/touxiang.jpg',
-                hou: 'https://houseoss.4dkankan.com/project/DEMO/staticResource/touxiang.jpg'
-              },
-              {
-                id: 3,
-                name: '附件信息',
-                qian: [
-                  {
-                    name: '666.jpg',
-                    src: 'https://houseoss.4dkankan.com/project/DEMO/staticResource/touxiang.jpg'
-                  }
-                ],
-                hou: [
-                  {
-                    name: '666.jpg',
-                    src: 'https://houseoss.4dkankan.com/project/DEMO/staticResource/touxiang.jpg'
-                  },
-                  {
-                    name: '777.mp4',
-                    src: 'https://houseoss.4dkankan.com/project/DEMO/staticResource/loop.mp4'
-                  }
-                ]
-              },
-              { id: 4, name: '简介', qian: '11', hou: '22' }
-            ]}
+            rowKey='name'
+            list={oldNewArr}
             columnsTemp={[]}
             lastBtn={tableLastBtn2}
             pagingInfo={false}
@@ -411,15 +593,7 @@ function C6add() {
         </div>
 
         {/* 申请流程 */}
-        {['3', '4'].includes(key) ? (
-          <B3flowTable
-            tableArr={
-              [
-                //  待完善
-              ]
-            }
-          />
-        ) : null}
+        {['3', '4'].includes(key) ? <B3flowTable tableArr={topInfo.audits || []} /> : null}
       </div>
 
       {/* 底部按钮 */}
@@ -428,12 +602,18 @@ function C6add() {
           lookBtn
         ) : (
           <>
-            <Button type='primary' onClick={() => btnClickFu(1)}>
-              {key === '1' ? '创建' : '保存'}
-            </Button>
+            {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(2)}>
+              <Button type='primary' onClick={() => btnClickFu('草稿')}>
                 存草稿
               </Button>
             ) : null}
@@ -447,7 +627,6 @@ function C6add() {
       <Y1cathet sId={cathet} closeFu={() => setCathet(0)} />
 
       {/* 所选藏品弹窗 / 继续编辑 */}
-
       {nowSta.id ? (
         nowSta.type === 'now' ? (
           <B3GaddNow
@@ -455,26 +634,84 @@ function C6add() {
             nowSta={nowSta}
             closeFu={() => setNowSta({ key: '', id: '', type: '' })}
             dataResFu={data => {
-              setListTemp([{ id: 99, thumb: '', num: '一段编号_可点击' }])
+              setTopInfo({ ...topInfo, goods: data })
               setTimeout(() => {
-                setNowSta({ key: '7', id: '77', type: 'new' })
+                setNowSta({ key: '7', id: data[0].id + '', type: 'new' })
               }, 20)
+
+              // 编辑明细清空
+              if (topInfo.goods && topInfo.goods[0] && data[0].id !== topInfo.goods[0].id) {
+                setOldNewArr([])
+              }
             }}
-            // 待完善
-            oldCheckArr={[]}
+            oldCheckArr={topInfo.goods || []}
           />
         ) : (
           <B3GaddNew
             nowSta={nowSta}
             closeFu={() => setNowSta({ key: '', id: '', type: '' })}
             isEdit={true}
-            succFu={obj => {}}
+            succFu={(newObj, _, fileNewTemp, fileOldTemp) => {
+              const arrRes: OldNewType[] = []
+
+              oldNewTxtArr.forEach(v => {
+                const oldInfo = topInfo.goods[0]
+                let oldTxt = oldInfo[v.key]
+                let newTxt = newObj[v.key] as string
+
+                if ((oldTxt || newTxt) && oldTxt !== newTxt && v.name !== '制档日期') {
+                  if (v.backFu && v.name !== '备注') oldTxt = v.backFu(oldInfo)
+                  if (v.backFu && v.name !== '备注') newTxt = v.backFu(newObj)
+
+                  arrRes.push({
+                    name: v.name,
+                    qian: oldTxt,
+                    hou: newTxt
+                  })
+                }
+              })
+
+              // 附件信息的对比
+
+              const fileOld = fileOldTemp || []
+              const fileNew = fileNewTemp || []
+
+              const fileOldIds = fileOld.map(v => v.id).join('')
+
+              const fileNewIds = fileNew.map(v => v.id).join('')
+
+              if (fileOldIds !== fileNewIds) {
+                arrRes.push({
+                  name: '附件信息',
+                  qian: fileOld.map(
+                    v =>
+                      ({
+                        id: v.id,
+                        fileName: v.fileName,
+                        filePath: v.filePath
+                      } as GoodFileType)
+                  ),
+                  hou: fileNew.map(
+                    v =>
+                      ({
+                        id: v.id,
+                        fileName: v.fileName,
+                        filePath: v.filePath
+                      } as GoodFileType)
+                  )
+                })
+              }
+
+              setTopInfo({ ...topInfo, tempGoodsJson: newObj })
+
+              setOldNewArr(arrRes)
+            }}
           />
         )
       ) : null}
 
       {/* 查看富文本 */}
-      {look ? <X2lookText closeFu={() => setLook('')} text='待完善' /> : null}
+      {look ? <X2lookText closeFu={() => setLook('')} text={look} /> : null}
     </div>
   )
 }

+ 3 - 0
src/pages/C_goodsManage/C6edit/index.module.scss

@@ -19,6 +19,9 @@
           }
         }
       }
+      .ant-select-selection-placeholder {
+        color: black;
+      }
     }
     .ant-table-cell {
       padding: 8px !important;

+ 97 - 28
src/pages/C_goodsManage/C6edit/index.tsx

@@ -3,17 +3,25 @@ import styles from './index.module.scss'
 import { B3_4inputKeyArr, B3baseFormData, D3InputKeyType } from '@/pages/B_enterTibet/B3_4page'
 import { Button, DatePicker, Input, Select } from 'antd'
 import MyPopconfirm from '@/components/MyPopconfirm'
-import history from '@/utils/history'
+import history, { btnFlagFu } from '@/utils/history'
 import dayjs from 'dayjs'
 import MyTable from '@/components/MyTable'
-import { B3tableC } from '@/utils/tableData'
+import { B3tableC, statusObj } from '@/utils/tableData'
+import { useDispatch, useSelector } from 'react-redux'
+import { C6_APIdel, C6_APIgetList } from '@/store/action/C6edit'
+import { RootState } from '@/store'
+import { MessageFu } from '@/utils/message'
+import { FourTableType } from '@/pages/B_enterTibet/B3_4page/type'
+import ExportJsonExcel from 'js-export-excel'
+import { selectObj } from '@/utils/select'
 const { RangePicker } = DatePicker
 
 function C6edit() {
-  // 没有接入后端 待完善
+  const dispatch = useDispatch()
 
   const [formData, setFormData] = useState(B3baseFormData)
   const formDataRef = useRef(B3baseFormData)
+  const formDataOldRef = useRef(B3baseFormData)
 
   useEffect(() => {
     formDataRef.current = formData
@@ -46,8 +54,12 @@ function C6edit() {
 
   // 封装发送请求的函数
   const getListFu = useCallback(() => {
-    console.log('发送请求', formDataRef.current)
-  }, [])
+    formDataOldRef.current = { ...formDataRef.current }
+    dispatch(C6_APIgetList(formDataRef.current))
+  }, [dispatch])
+
+  // 从仓库中获取数据
+  const tableInfo = useSelector((state: RootState) => state.C6edit.tableInfo)
 
   useEffect(() => {
     getListFu()
@@ -86,7 +98,11 @@ function C6edit() {
   // 点击删除
   const delTableFu = useCallback(
     async (id: number) => {
-      getListFu()
+      const res = await C6_APIdel(id)
+      if (res.code === 0) {
+        MessageFu.success('删除成功')
+        getListFu()
+      }
     },
     [getListFu]
   )
@@ -95,25 +111,36 @@ function C6edit() {
   const btnFu = useCallback((id: number | string, key: string) => {
     history.push(`/edit_add/${key}/${id}`)
   }, [])
-
   const tableLastBtn = useMemo(() => {
-    //   看状态和账号角色显示按钮 待完善
     return [
       {
         title: '操作',
-        render: (item: any) => {
-          return (
+        render: (item: FourTableType) => {
+          let obj = btnFlagFu(item)
+          return !Object.values(obj).some(Boolean) ? (
+            '-'
+          ) : (
             <>
-              <Button size='small' type='text' onClick={() => btnFu(item.id, '2')}>
-                编辑
-              </Button>
-              <Button size='small' type='text' onClick={() => btnFu(item.id, '3')}>
-                审批
-              </Button>
-              <Button size='small' type='text' onClick={() => btnFu(item.id, '4')}>
-                查看
-              </Button>
-              <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
+              {obj['编辑'] ? (
+                <Button size='small' type='text' onClick={() => btnFu(item.id, '2')}>
+                  编辑
+                </Button>
+              ) : null}
+
+              {obj['审批'] ? (
+                <Button size='small' type='text' onClick={() => btnFu(item.id, '3')}>
+                  审批
+                </Button>
+              ) : null}
+              {obj['查看'] ? (
+                <Button size='small' type='text' onClick={() => btnFu(item.id, '4')}>
+                  查看
+                </Button>
+              ) : null}
+
+              {obj['删除'] ? (
+                <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
+              ) : null}
             </>
           )
         }
@@ -121,6 +148,43 @@ function C6edit() {
     ]
   }, [btnFu, delTableFu])
 
+  // 点击导出
+  const deriveFu = useCallback(async () => {
+    const name = '藏品编辑' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
+
+    const res = await C6_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', 'name', 'deptName', 'creatorName', 'createTime', 'status'],
+            sheetHeader: ['业务单号', '申请名称', '发起部门', '发送人', '发起日期', '申请状态'],
+            columnWidths: [10, 10, 10, 10, 10, 10]
+          }
+        ]
+      }
+
+      const toExcel = new ExportJsonExcel(option) //new
+      toExcel.saveExcel() //保存
+    }
+  }, [])
+
   return (
     <div className={styles.C6edit}>
       <div className='pageTitle'>藏品编辑</div>
@@ -139,7 +203,10 @@ function C6edit() {
           ))}
         </div>
         <div className='C6toprr'>
-          <Button type='primary'>批量导出</Button>&emsp;
+          <Button type='primary' onClick={deriveFu}>
+            批量导出
+          </Button>
+          &emsp;
           <Button type='primary' onClick={() => btnFu('null', '1')}>
             新增
           </Button>
@@ -160,21 +227,23 @@ function C6edit() {
           <div>
             <span>申请状态:</span>
             <Select
-              placeholder='请选择'
+              allowClear={true}
+              placeholder='全部'
               style={{ width: 200 }}
               value={formData.status}
               onChange={e => setFormData({ ...formData, status: e })}
-              options={[{ value: '', label: '全部' }]}
+              options={selectObj['申请状态'].filter(v => v.label !== '待盘点')}
             />
           </div>
 
           <div>
             <span>选择角色:</span>
             <Select
+              allowClear={true}
               style={{ width: 200 }}
-              placeholder='请选择'
-              options={[]}
-              fieldNames={{ value: 'id', label: 'roleName' }}
+              placeholder='全部'
+              options={selectObj['角色']}
+              // fieldNames={{ value: 'id', label: 'roleName' }}
               value={formData.userType}
               onChange={e => setFormData({ ...formData, userType: e })}
             />
@@ -191,12 +260,12 @@ function C6edit() {
       {/* 表格 */}
       <MyTable
         yHeight={610}
-        list={[{ id: 91 }]}
+        list={tableInfo.list}
         columnsTemp={B3tableC}
         lastBtn={tableLastBtn}
         pageNum={formData.pageNum}
         pageSize={formData.pageSize}
-        total={0}
+        total={tableInfo.total}
         onChange={(pageNum, pageSize) => paginationChange(pageNum, pageSize)}
       />
     </div>

+ 10 - 11
src/pages/D_storeManage/D4impStor/D4edit/index.tsx

@@ -161,15 +161,6 @@ function D4edit() {
       MessageFu.warning('请选择入库库房')
       return true
     }
-    if (!topInfo.goods || (topInfo.goods && topInfo.goods.length === 0)) {
-      MessageFu.warning('请添加藏品')
-      return true
-    } else {
-      if (topInfo.goods.some(v => !v.siteStr)) {
-        MessageFu.warning('请选择存放位置')
-        return true
-      }
-    }
 
     return false
   }, [topInfo])
@@ -180,6 +171,16 @@ function D4edit() {
   // 新增的底部按钮点击
   const btnClickFu = useCallback(
     async (val: '草稿' | '创建' | '保存' | '审批') => {
+      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('请选择存放位置')
+          }
+        }
+      }
+
       if (checkDataFu()) return
 
       if (val === '审批') {
@@ -443,8 +444,6 @@ function D4edit() {
     )
   }, [delFu, lookBtnFu, lookJumpFu, topInfo])
 
-  // 所有级联的数据平铺
-
   // 自动分配空置库位
   const autoNullFu = useCallback(async () => {
     const res = await D1_APIgetSiteList(topInfo.storageId!, true)

+ 10 - 9
src/pages/D_storeManage/D6putsStor/D6edit/index.tsx

@@ -146,15 +146,6 @@ function D6edit() {
       MessageFu.warning('请选择出库库房')
       return true
     }
-    if (!topInfo.goods || (topInfo.goods && topInfo.goods.length === 0)) {
-      MessageFu.warning('请添加藏品')
-      return true
-    } else {
-      if (topInfo.goods.some(v => !v.siteStr)) {
-        MessageFu.warning('请选择出库位置')
-        return true
-      }
-    }
 
     return false
   }, [topInfo])
@@ -165,6 +156,16 @@ function D6edit() {
   // 新增的底部按钮点击
   const btnClickFu = useCallback(
     async (val: '草稿' | '创建' | '保存' | '审批') => {
+      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('请选择出库位置')
+          }
+        }
+      }
+
       if (checkDataFu()) return
 
       if (val === '审批') {

+ 8 - 2
src/pages/Y_goodsDetails/Y1cathet/data.tsx

@@ -1,7 +1,7 @@
 import { C1GoodType } from '@/pages/C_goodsManage/C1ledger/type'
 import { resJiLianFu, textFu } from '@/utils/history'
 
-type ArrKeyType = {
+export type ArrKeyType = {
   name: string
   key: keyof C1GoodType
   full?: boolean
@@ -30,11 +30,17 @@ export const Y11infoArr2: ArrKeyType = [
   {
     name: '年代',
     key: 'dictAge',
+
     backFu: info => {
-      return info.dictAge === '其他' ? '其他 - ' + info.ageInfo : resJiLianFu(info.dictAge)
+      return info.dictAge === '其他' ? '其他' : resJiLianFu(info.dictAge)
     }
   },
   { name: '制作时间', key: 'dateMaking' },
+  {
+    name: '具体年代',
+    key: 'ageInfo',
+    full: true
+  },
   { name: '作者', key: 'author' },
   { name: '作者介绍', key: 'authorDesc' },
   {

+ 77 - 0
src/store/action/C6edit.ts

@@ -0,0 +1,77 @@
+import http from '@/utils/http'
+import { AppDispatch } from '..'
+/**
+ * 藏品编辑 - 获取分页列表
+ */
+export const C6_APIgetList = (data: any, exportFlag?: boolean): any => {
+  if (exportFlag) return http.post('cms/orderEdit/page', data)
+  else {
+    return async (dispatch: AppDispatch) => {
+      const res = await http.post('cms/orderEdit/page', data)
+      if (res.code === 0) {
+        const obj = {
+          list: res.data.records,
+          total: res.data.total
+        }
+
+        dispatch({ type: 'C6/getList', payload: obj })
+      }
+    }
+  }
+}
+
+/**
+ * 藏品编辑-删除
+ */
+export const C6_APIdel = (id: number) => {
+  return http.get(`cms/orderEdit/remove/${id}`)
+}
+
+/**
+ * 藏品编辑-创建订单
+ */
+export const C6_APIcreate = () => {
+  return http.get('cms/orderEdit/create')
+}
+
+/**
+ * 藏品编辑-获取详情
+ */
+export const C6_APIgetInfo = (id: number) => {
+  return http.get(`cms/orderEdit/detail/${id}`)
+}
+
+/**
+ * 藏品编辑-存草稿
+ */
+export const C6_APIsaveDraft = (data: any) => {
+  return http.post('cms/orderEdit/saveDraft', data)
+}
+
+/**
+ * 藏品编辑-创建
+ */
+export const C6_APIsaveCreate = (data: any) => {
+  return http.post('cms/orderEdit/saveCreate', data)
+}
+
+/**
+ * 藏品编辑-编辑保存
+ */
+export const C6_APIsaveApply = (data: any) => {
+  return http.post('cms/orderEdit/saveApply', data)
+}
+
+/**
+ * 藏品编辑-审批
+ */
+export const C6_APIsaveAudit = (data: any) => {
+  return http.post('cms/orderEdit/audit', data)
+}
+
+/**
+ * 藏品编辑-撤回订单
+ */
+export const C6_APIrevocation = (id: number) => {
+  return http.get(`cms/orderEdit/revocation/${id}`)
+}

+ 28 - 0
src/store/reducer/C6edit.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: 'C6/getList'
+  payload: { list: FourTableType[]; total: number }
+}
+
+// reducer
+export default function userReducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case 'C6/getList':
+      return { ...state, tableInfo: action.payload }
+
+    default:
+      return state
+  }
+}

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

@@ -6,6 +6,7 @@ import A0Layout from './layout'
 import FourAll from './FourAll'
 import C1ledger from './C1ledger'
 import C2files from './C2files'
+import C6edit from './C6edit'
 import D2storSet from './D2storSet'
 import D4impStor from './D4impStor'
 import D6putsStor from './D6putsStor'
@@ -23,6 +24,7 @@ const rootReducer = combineReducers({
   FourAll,
   C1ledger,
   C2files,
+  C6edit,
   D2storSet,
   D4impStor,
   D6putsStor,