Sfoglia il codice sorgente

Merge branch 'master' of http://192.168.0.115:3000/shaogen1995/qingDao_goods into master

shaogen1995 23 ore fa
parent
commit
0e269f714e

+ 9 - 8
src/pages/Abench/A1statistics/index.tsx

@@ -231,8 +231,9 @@ function A1statistics() {
 
     const myChart = echarts.getInstanceByDom(dom) || echarts.init(dom)
 
-    // 计算总数用于百分比
+    // 计算总数用于百分比(total 为 0 时避免 NaN)
     const total = data.reduce((sum, item) => sum + item.value, 0)
+    const pct = (val: number) => (total > 0 ? ((val / total) * 100).toFixed(1) + '%' : '0%')
     const dataMax = Math.max(...data.map(d => d.value))
     const yMax = Math.max(5, dataMax)
     const yInterval = Math.max(1, Math.ceil(yMax / 5))
@@ -248,7 +249,7 @@ function A1statistics() {
           return `
                   <div style="font-weight: bold;">${param.name}</div>
                   <div>数量: ${param.value}</div>
-                  <div>占比: ${((param.value / total) * 100).toFixed(1) + '%'}</div>
+                  <div>占比: ${pct(param.value)}</div>
                 `
         },
         backgroundColor: 'rgba(255, 255, 255, 0.95)',
@@ -325,7 +326,7 @@ function A1statistics() {
           type: 'bar',
           data: data.map((item, index) => ({
             value: item.value,
-            percentage: ((item.value / total) * 100).toFixed(1) + '%',
+            percentage: pct(item.value),
             // 为每个柱子设置独立的渐变
             itemStyle: {
               // 关键修改:使用线性渐变实现单个柱子的渐变效果
@@ -353,7 +354,7 @@ function A1statistics() {
             position: 'top',
             formatter: (params: any) => {
               const itemData = params.data
-              return `${itemData.value}\n${((itemData.value / total) * 100).toFixed(1) + '%'}`
+              return `${itemData.value}\n${pct(itemData.value)}`
             },
             fontSize: 10,
             fontWeight: 'bold',
@@ -397,14 +398,15 @@ function A1statistics() {
 
     // 有数据时先清除,避免从「暂无数据」切换后 graphic 残留
     myChart.clear()
-    // 计算总数用于百分比
+    // 计算总数用于百分比(total 为 0 时避免 NaN)
     const total = data.reduce((sum, item) => sum + item.value, 0)
+    const pct = (val: number) => (total > 0 ? ((val / total) * 100).toFixed(1) : '0')
 
     const option = {
       color: DEFAULT_COLORS, // 设置颜色方案
       tooltip: {
         trigger: 'item',
-        formatter: '{b}: {c} ({d}%)'
+        formatter: (params: any) => `${params.name}: ${params.value} (${pct(params.value)}%)`
       },
       legend: {
         type: 'scroll',
@@ -418,8 +420,7 @@ function A1statistics() {
         formatter: function (name: string) {
           const item = data.find(d => d.name === name)
           if (item) {
-            const percent = ((item.value / total) * 100).toFixed(1)
-            return `${name}  ${item.value}  ${percent}%`
+            return `${name}  ${item.value}  ${pct(item.value)}%`
           }
           return name
         }

+ 20 - 3
src/pages/Cledger/C1ledger/C1Import/index.tsx

@@ -163,11 +163,16 @@ function C1Import({ onClose }: { onClose: () => void }) {
             ref={fileInputRef}
             type='file'
             accept={isImportData ? '.xlsx' : '.zip,.rar'}
+            maxLength={1000}
+            max={isImportData ? 10 * 1024 * 1024 : 500 * 1024 * 1024}
             style={{ display: 'none' }}
             onChange={isImportData ? handleUploadExcel : handleUploadZip}
           />
           {isImportData ? (
             <>
+              <div style={{ marginRight: 20 }}>
+                仅支持xlsx格式,文件不得大于10M,单词最多上传1000条
+              </div>
               <Button
                 type='primary'
                 onClick={() => window.open(`${baseURL}/baseData/ZP_TEMP.xlsx`)}
@@ -179,9 +184,21 @@ function C1Import({ onClose }: { onClose: () => void }) {
               </Button>
             </>
           ) : (
-            <Button type='primary' onClick={() => fileInputRef.current?.click()}>
-              上传压缩包(ZIP,RAR格式)
-            </Button>
+            <>
+              <div style={{ marginRight: 20 }}>
+                图片以zip压缩包格式上传,500M以内,请勿嵌套
+                <br />
+                图片命名规则:藏品编号-图片类型(如D00001-A-01)
+              </div>
+              <div style={{ marginRight: 20 }}>
+                图片的格式:jpg/png/bmp/gif
+                <br />
+                图片类型:A:正视图 B:俯视图 C:侧视图 D:全景图 E:局部图 F:底部图
+              </div>
+              <Button type='primary' onClick={() => fileInputRef.current?.click()}>
+                上传压缩包(ZIP,RAR格式)
+              </Button>
+            </>
           )}
         </div>
       </>

+ 28 - 7
src/pages/Cledger/C1ledger/C1ImportRes/index.tsx

@@ -25,8 +25,9 @@ function C1ImportRes({ onClose, tableInfo, uploadFu, isLook = false }: Props) {
     {
       title: '失败原因',
       render: (_: any, record: any) => {
-        const isFail = record.importIsTrue === 0 || record.importIsTrue === 0
-        const errArr = record.EError ?? record.eerror ?? []
+        const isFail = record.importIsTrue === 0
+        const errArr = record.importErrorMsg ?? record.EError ?? record.eerror ?? []
+        // console.log('errArr', errArr)
         if (!isFail) return ''
         return Array.isArray(errArr) ? (
           <span style={{ whiteSpace: 'pre-line' }}>{errArr.join('\n')}</span>
@@ -52,6 +53,8 @@ function C1ImportRes({ onClose, tableInfo, uploadFu, isLook = false }: Props) {
   const [searchKey, setSearchKey] = useState('')
   const [checkResult, setCheckResult] = useState()
   const [importLoading, setImportLoading] = useState(false)
+  const [pageNum, setPageNum] = useState(1)
+  const [pageSize, setPageSize] = useState(10)
   const fileInputRef = useRef<HTMLInputElement>(null)
   // 条件搜索(保留 _rowKey 用于表格 key)
   useEffect(() => {
@@ -67,6 +70,7 @@ function C1ImportRes({ onClose, tableInfo, uploadFu, isLook = false }: Props) {
         return matchesSearch && matchesCheck
       })
     setTableInfoData(filtered)
+    setPageNum(1) // 搜索/筛选变化时重置到第一页
   }, [tableInfo.excel, searchKey, checkResult])
 
   // 重新上传
@@ -101,11 +105,21 @@ function C1ImportRes({ onClose, tableInfo, uploadFu, isLook = false }: Props) {
         // 2. 再导入数据
         const importId = recordRes.data.id
         const res: any = await API_addImportExcel(
-          successData.map((item: any) => ({
-            ...item,
-            importId,
-            importError: item.importIsTrue === 0 ? 1 : 0
-          })) as any
+          successData.map((item: any) => {
+            const obj = {
+              ...item,
+              importId,
+              importError: item.importIsTrue === 0 ? 1 : 0
+            }
+            // 过滤掉值为 null 的属性
+            // console.log(
+            //   'obj',
+            //   Object.fromEntries(Object.entries(obj).filter(([, v]) => v != null && v !== 'null'))
+            // )
+            return Object.fromEntries(
+              Object.entries(obj).filter(([, v]) => v != null && v !== 'null')
+            ) as any
+          })
         )
         if (res?.code === 0) {
           MessageFu.success('导入成功')
@@ -170,6 +184,13 @@ function C1ImportRes({ onClose, tableInfo, uploadFu, isLook = false }: Props) {
           yHeight={500}
           staBtn={staBtn}
           lastBtn={lastBtn}
+          pageNum={pageNum}
+          pageSize={pageSize}
+          total={tableInfoData.length}
+          onChange={(p, s) => {
+            setPageNum(p)
+            setPageSize(s)
+          }}
         />
       </div>
       <div className={styles.TableListBottom}>

+ 10 - 0
src/pages/Cledger/C1ledger/C1importZipRes/index.tsx

@@ -26,6 +26,8 @@ function C1ImportZipRes({ onClose, tableInfo, uploadFu, isLook = false }: Props)
   const [searchKey, setSearchKey] = useState('')
   const [checkResult, setCheckResult] = useState()
   const [importLoading, setImportLoading] = useState(false)
+  const [pageNum, setPageNum] = useState(1)
+  const [pageSize, setPageSize] = useState(10)
   const fileInputRef = useRef<HTMLInputElement>(null)
 
   // 条件搜索
@@ -37,6 +39,7 @@ function C1ImportZipRes({ onClose, tableInfo, uploadFu, isLook = false }: Props)
       return matchesSearch && matchesCheck
     })
     setTableInfoData(filtered)
+    setPageNum(1) // 搜索/筛选变化时重置到第一页
   }, [tableInfo.img, searchKey, checkResult])
 
   // 重新上传
@@ -137,6 +140,13 @@ function C1ImportZipRes({ onClose, tableInfo, uploadFu, isLook = false }: Props)
           list={tableInfoData}
           columnsTemp={importZipDataTableCheckC}
           yHeight={500}
+          pageNum={pageNum}
+          pageSize={pageSize}
+          total={tableInfoData.length}
+          onChange={(p, s) => {
+            setPageNum(p)
+            setPageSize(s)
+          }}
         />
       </div>
       <div className={styles.TableListBottom}>