shaogen1995 2 месяцев назад
Родитель
Сommit
72d39fa554

+ 2 - 2
public/index.html

@@ -12,8 +12,8 @@
 
     <script>
       // 域名地址
-      const baseUrlTempOne = 'https://sit-yiwubwg.4dage.com'
-      // const baseUrlTempOne = 'http://192.168.20.61:8096'
+      // const baseUrlTempOne = 'https://sit-yiwubwg.4dage.com'
+      const baseUrlTempOne = 'http://192.168.20.61:8096'
 
       // 钉钉模式
       const isDingTemp = false

+ 2 - 2
src/components/ZupFile/index.tsx

@@ -4,7 +4,7 @@ import { InboxOutlined } from '@ant-design/icons'
 import { MessageFu } from '@/utils/message'
 import styles from './index.module.scss'
 import { B1Xtype } from '@/pages/B_enterTibet/B1collect/data'
-import { baseURL } from '@/utils/http'
+import { baseURL, envFlag } from '@/utils/http'
 import { fileTypeRes } from '@/store/action/layout'
 import { getTokenFu } from '@/utils/storage'
 import { API_C2dels } from '@/store/action/C2files'
@@ -33,7 +33,7 @@ function ZupFile({ tableList, moduleId, isShow, closeFu, succFu }: Props) {
     // 支持上传文件夹
     directory: true,
     multiple: true,
-    action: baseURL + '/api/cms/orderCollect/upload',
+    action: `${baseURL}${envFlag ? '' : '/api/'}cms/orderCollect/upload`,
     headers: {
       token: getTokenFu()
     },

+ 1 - 7
src/pages/A3_ledger/C1ledger/index.tsx

@@ -256,13 +256,7 @@ function C1ledger() {
       <div className='pageTitle'>
         {antiqueSearch ? '藏品信息' : '藏品总账'}
         {recycleBin ? '-回收站' : ''}
-        {importPage ? (
-          <>
-            -数据导入<span className='C4tit'>最多支持单次导入1000条</span>
-          </>
-        ) : (
-          ''
-        )}
+        {importPage ? <>-数据导入</> : ''}
       </div>
       {/* 第一行 */}
       <div className='C1top'>

+ 20 - 0
src/pages/A3_ledger/ComPage/C4import/C4impImg/index.module.scss

@@ -0,0 +1,20 @@
+.C4impImg {
+  :global {
+    .C4Itop {
+      display: flex;
+      margin-bottom: 10px;
+      & > div {
+        position: relative;
+        top: -3px;
+        margin-left: 30px;
+        font-size: 16px;
+        & > p {
+          margin-bottom: 5px;
+          & > span {
+            font-weight: 700;
+          }
+        }
+      }
+    }
+  }
+}

+ 123 - 0
src/pages/A3_ledger/ComPage/C4import/C4impImg/index.tsx

@@ -0,0 +1,123 @@
+import React, { useCallback, useMemo, useRef } from 'react'
+import styles from './index.module.scss'
+import { Button } from 'antd'
+import { MessageFu } from '@/utils/message'
+import { fileDomInitialFu } from '@/utils/domShow'
+import { API_upFile } from '@/store/action/layout'
+import MyTable from '@/components/MyTable'
+import { C4tableCImg } from '@/utils/tableData'
+
+type Props = {
+  hidden: boolean
+}
+
+function C4impImg({ hidden }: Props) {
+  // 上传表格数据
+  const upBiaoGeRef = useRef<HTMLInputElement>(null)
+
+  // 上传表格处理函数
+  const upBiaoGeFu = useCallback(async (e: React.ChangeEvent<HTMLInputElement>) => {
+    if (e.target.files) {
+      // 拿到files信息
+      const filesInfo = e.target.files[0]
+
+      // 校验格式
+      if (
+        !filesInfo.name.toLowerCase().endsWith('.zip') &&
+        !filesInfo.name.toLowerCase().endsWith('.rar')
+      ) {
+        e.target.value = ''
+        return MessageFu.warning(`只支持zip/rar格式!`)
+      }
+
+      // 创建FormData对象
+      const fd = new FormData()
+
+      fd.append('file', filesInfo)
+      fd.append('type', 'doc')
+      fd.append('dirCode', 'C4machineRegImg')
+      fd.append('isDb', 'true')
+
+      // 开启压缩图片
+      fd.append('isCompress', 'true')
+
+      e.target.value = ''
+
+      try {
+        const res = await API_upFile(fd, 'cms/import/im/upload/zip')
+
+        if (res.code === 0) {
+          MessageFu.success('上传成功!')
+          const arrAll: any[] = res.data || []
+          console.log('-------', res)
+        }
+        fileDomInitialFu()
+      } catch (error) {
+        console.error(error)
+
+        fileDomInitialFu()
+      }
+    }
+  }, [])
+
+  const tableLastBtn = useMemo(() => {
+    return [
+      {
+        title: '导入结果',
+        render: (item: any) => (
+          <Button size='small' type='text'>
+            查看
+          </Button>
+        )
+      },
+      {
+        title: '操作',
+        render: (item: any) => {
+          return (
+            <Button size='small' type='text' danger>
+              删除记录
+            </Button>
+          )
+        }
+      }
+    ]
+  }, [])
+
+  return (
+    <div className={styles.C4impImg} hidden={hidden}>
+      <input
+        id='upInput'
+        type='file'
+        accept='.zip,.rar'
+        ref={upBiaoGeRef}
+        onChange={e => upBiaoGeFu(e)}
+      />
+
+      <div className='C4Itop'>
+        <Button type='primary' size='large' onClick={() => upBiaoGeRef.current?.click()}>
+          上传压缩包(ZIP,RAR格式)
+        </Button>
+        <div>
+          <p>图片需压缩成zip压缩包格式 &emsp;&emsp;图片的格式:jpg/png/bmp/gif,10M以内</p>
+          <p>
+            图片命名规则:藏品编号-图片类型-图片序号<span>(如D00001-A-01)</span>&emsp;&emsp;
+            图片类型:A:正视图 B:俯视图 C:侧视图 D:全景图 E:局部图 F:底部图
+          </p>
+        </div>
+      </div>
+
+      <MyTable
+        classKey='C4impImg'
+        yHeight={638}
+        list={[]}
+        columnsTemp={C4tableCImg}
+        lastBtn={tableLastBtn}
+        pagingInfo={false}
+      />
+    </div>
+  )
+}
+
+const MemoC4impImg = React.memo(C4impImg)
+
+export default MemoC4impImg

+ 11 - 1
src/pages/A3_ledger/ComPage/C4import/index.module.scss

@@ -12,8 +12,18 @@
     .C4top {
       display: flex;
       justify-content: space-between;
-      margin-bottom: 35px;
+      margin-bottom: 20px;
       font-size: 16px;
+
+      .C4top11 {
+        display: inline-block;
+        margin-right: 200px;
+        .ant-btn {
+          margin-left: 0px;
+          margin-right: 15px;
+        }
+      }
+
       .jianGe {
         display: inline-block;
         width: 100px;

+ 84 - 16
src/pages/A3_ledger/ComPage/C4import/index.tsx

@@ -4,21 +4,25 @@ import { Button } from 'antd'
 import MyTable from '@/components/MyTable'
 import { C4tableC } from '@/utils/tableData'
 import MyPopconfirm from '@/components/MyPopconfirm'
+import { baseURL } from '@/utils/http'
+import B1upXLSX from '@/pages/B_enterTibet/B1collect/B1edit/B1upXLSX'
+import { TypeinfoXLSX } from '@/pages/B_enterTibet/B1collect/type'
+import C4impImg from './C4impImg'
 
 type Props = {
   colseFu: (flag: boolean) => void
 }
 
 function C4import({ colseFu }: Props) {
+  const [acTxt, setAcTxt] = useState('导入藏品数据')
+
   const tableLastBtn = useMemo(() => {
     return [
       {
         title: '导入结果',
         render: (item: any) => (
           <Button size='small' type='text'>
-            <a href={item.src} download target='_blank' rel='noreferrer'>
-              下载
-            </a>
+            查看
           </Button>
         )
       },
@@ -26,13 +30,9 @@ function C4import({ colseFu }: Props) {
         title: '操作',
         render: (item: any) => {
           return (
-            <>
-              <MyPopconfirm txtK='导入当前合格数据' onConfirm={() => {}} />
-              <Button size='small' type='text' onClick={() => setList([])}>
-                重新上传
-              </Button>
-              <MyPopconfirm txtK='清空数据' onConfirm={() => {}} />
-            </>
+            <Button size='small' type='text' danger>
+              删除记录
+            </Button>
           )
         }
       }
@@ -44,20 +44,88 @@ function C4import({ colseFu }: Props) {
   const flagRef = useRef(false)
   // 导入合格数据之后变成true
 
+  const B1upXLSXRef = useRef<any>(null)
+
+  // 上传表格数据
+  const [infoXLSX, setInfoXLSX] = useState<TypeinfoXLSX>({
+    show: false,
+    succ: [],
+    err: []
+  })
+
   // 待完善
   return (
     <div className={styles.C4import}>
       <div className='C4top'>
         <div>
-          一普数据<Button type='primary'>上传表格</Button>
-          <Button>下载模板</Button>
-          <span className='jianGe'></span>
-          省平台数据<Button type='primary'>上传表格</Button>
-          <Button>下载模板</Button>
+          <span className='C4top11'>
+            {['导入藏品数据', '导入藏品图片'].map(v => (
+              <Button
+                onClick={() => setAcTxt(v)}
+                key={v}
+                type={acTxt === v ? 'primary' : 'default'}
+              >
+                {v}
+              </Button>
+            ))}
+          </span>
+          {acTxt === '导入藏品数据' ? (
+            <>
+              一普数据{' '}
+              <a
+                href={`${baseURL}/baseData/ZP_TEMP.xlsx`}
+                download='一普数据模板'
+                target='_blank'
+                rel='noreferrer'
+              >
+                <Button>下载模板</Button>
+              </a>
+              <Button type='primary' onClick={() => B1upXLSXRef.current?.openUpFu('1')}>
+                上传表格
+              </Button>
+              <span className='jianGe'></span>
+              省平台数据{' '}
+              <a
+                href={`${baseURL}/baseData/ZP_TEMP.xlsx`}
+                download='省平台数据模板'
+                target='_blank'
+                rel='noreferrer'
+              >
+                <Button>下载模板</Button>
+              </a>
+              <Button type='primary' onClick={() => B1upXLSXRef.current?.openUpFu('2')}>
+                上传表格
+              </Button>
+              <span className='C4tit'>每组数据最多1000条</span>
+              <B1upXLSX
+                ref={B1upXLSXRef}
+                closeFu={() => setInfoXLSX({ show: false, succ: [], err: [] })}
+                infoXLSX={infoXLSX}
+                upSuccFu={(succ, err) => setInfoXLSX({ show: true, succ, err })}
+                isZongZhang={true}
+                clickSuccFu={arr => {
+                  // 导入成功
+                  flagRef.current = true
+                }}
+              />
+            </>
+          ) : null}
         </div>
         <Button onClick={() => colseFu(flagRef.current)}>返回</Button>
       </div>
-      <MyTable list={list} columnsTemp={C4tableC} lastBtn={tableLastBtn} pagingInfo={false} />
+
+      <div hidden={acTxt !== '导入藏品数据'}>
+        <MyTable
+          classKey='C4import'
+          yHeight={700}
+          list={list}
+          columnsTemp={C4tableC}
+          lastBtn={tableLastBtn}
+          pagingInfo={false}
+        />
+      </div>
+
+      <C4impImg hidden={acTxt === '导入藏品数据'} />
 
       {/* 表格 */}
     </div>

+ 26 - 6
src/pages/B_enterTibet/B1collect/B1edit/B1upXLSX/index.tsx

@@ -10,6 +10,8 @@ import { B1Xtype } from '../../data'
 import MyTable from '@/components/MyTable'
 import { B1TableC2up } from '@/utils/tableData'
 import { B1X_APIadds } from '@/store/action/B1collect'
+import { forwardRef, useImperativeHandle } from 'react'
+
 // 删掉前面2个
 const arrTemp = ['dictAge', 'dictAgeFirst', 'dictType', 'source']
 
@@ -18,9 +20,14 @@ type Props = {
   infoXLSX: TypeinfoXLSX
   upSuccFu: (succArr: B1Xtype[], errArr: B1Xtype[]) => void
   clickSuccFu: (arr: B1Xtype[]) => void
+  isZongZhang?: boolean
+  ref: any //当前自己的ref,给父组件调用
 }
 
-function B1upXLSX({ closeFu, infoXLSX, clickSuccFu, upSuccFu }: Props) {
+function B1upXLSX({ closeFu, infoXLSX, clickSuccFu, upSuccFu, isZongZhang }: Props, ref: any) {
+  // 藏品总账导入的类型 一普 和省平台
+  const zongZhnagType = useRef('')
+
   // 上传表格数据
   const upBiaoGeRef = useRef<HTMLInputElement>(null)
 
@@ -32,7 +39,7 @@ function B1upXLSX({ closeFu, infoXLSX, clickSuccFu, upSuccFu }: Props) {
         const filesInfo = e.target.files[0]
 
         // 校验格式
-        if (!filesInfo.name.includes('.xlsx')) {
+        if (!filesInfo.name.toLowerCase().endsWith('.xlsx')) {
           e.target.value = ''
           return MessageFu.warning(`只支持xlsx格式!`)
         }
@@ -97,9 +104,24 @@ function B1upXLSX({ closeFu, infoXLSX, clickSuccFu, upSuccFu }: Props) {
     }
   }, [clickSuccFu, closeFu, infoXLSX.succ])
 
+  // 让父组件调用
+  const openUpFu = useCallback((val: string) => {
+    console.log(123, val)
+    zongZhnagType.current = val
+
+    // upBiaoGeRef.current?.click()
+  }, [])
+
+  // 可以让父组件调用子组件的方法
+  useImperativeHandle(ref, () => ({
+    openUpFu
+  }))
+
   return (
     <>
-      <Button onClick={() => upBiaoGeRef.current?.click()}>上传表格数据</Button>
+      <Button hidden={isZongZhang} onClick={() => upBiaoGeRef.current?.click()}>
+        上传表格数据
+      </Button>
       <input
         id='upInput'
         type='file'
@@ -161,6 +183,4 @@ function B1upXLSX({ closeFu, infoXLSX, clickSuccFu, upSuccFu }: Props) {
   )
 }
 
-const MemoB1upXLSX = React.memo(B1upXLSX)
-
-export default MemoB1upXLSX
+export default forwardRef(B1upXLSX)

+ 5 - 1
src/pages/Z_system/Z4organization/index.module.scss

@@ -41,7 +41,7 @@
           .Z4mr2 {
             .Z4mr2Row {
               display: flex;
-              align-items: center;
+              // align-items: center;
               margin-bottom: 10px;
               font-size: 20px;
               .Z4mr2Row1 {
@@ -60,9 +60,13 @@
                 text-overflow: ellipsis;
                 white-space: nowrap;
               }
+              .Z4mr2Row2_1 {
+                width: calc(100% - 105px);
+              }
             }
             .Z4mr2Row0 {
               margin-bottom: 0;
+              align-items: center;
             }
             .Z4mr2RowLast {
               align-items: self-start;

+ 1 - 1
src/pages/Z_system/Z4organization/index.tsx

@@ -175,7 +175,7 @@ function Z4organization() {
 
                   <div className='Z4mr2Row'>
                     <div className='Z4mr2Row1'>部门说明:</div>
-                    <div className='Z4mr2Row2'>{rightData.description || '(空)'}</div>
+                    <div className='Z4mr2Row2_1'>{rightData.description || '(空)'}</div>
                   </div>
 
                   <div className='Z4mr2Row'>

+ 1 - 1
src/utils/http.ts

@@ -8,7 +8,7 @@ import { loginOutFu } from '@/components/DingLogin/data'
 // 是否是钉钉登录
 export const isDing = isDingTemp
 
-const envFlag = process.env.NODE_ENV === 'development'
+export const envFlag = process.env.NODE_ENV === 'development'
 
 const baseUrlTemp = baseUrlTempOne // 测试环境
 // export const baseUrlTemp = 'http://192.168.20.61:8096' // 线下环境

+ 16 - 3
src/utils/tableData.ts

@@ -216,9 +216,22 @@ export const C2tableC = [
 // 待完善
 export const C4tableC = [
   ['txt', '数据类型', 'type'],
-  ['txt', '导入数据行数', 'hang1'],
-  ['txt', '合格数据行数', 'hang2'],
-  ['txt', '异常数据行数', 'hang3']
+  ['txt', '文件名称', 'hang1'],
+  ['txt', '导入数据', 'hang2'],
+  ['txt', '成功数据', 'hang3'],
+  ['txt', '失败数据', 'hang3'],
+  ['txt', '导入日期', 'hang3'],
+  ['txt', '导入用户', 'hang3']
+]
+
+// 待完善
+export const C4tableCImg = [
+  ['txt', '文件名称', 'hang1'],
+  ['txt', '导入数据', 'hang2'],
+  ['txt', '成功数据', 'hang3'],
+  ['txt', '失败数据', 'hang3'],
+  ['txt', '导入日期', 'hang3'],
+  ['txt', '导入用户', 'hang3']
 ]
 
 // V1.1.1藏品编辑