shaogen1995 1 tydzień temu
rodzic
commit
5e85d3651b

+ 35 - 21
src/pages/A1check/A3result/index.tsx

@@ -8,6 +8,29 @@ import { useSelector } from 'react-redux'
 import { RootState } from '@/store'
 import { Button } from 'antd'
 import { openLink } from '@/utils/history'
+import dayjs from 'dayjs'
+
+const columnsTemp = [
+  ['index', '序号', 100],
+  ['txt2', '编号类型', 'numName', 150],
+  ['txt2', '编号', 'num', 150],
+  ['txt2', '名称', 'name', 150],
+  ['txt', '级别', 'level'],
+  ['txt', '类别', 'type'],
+  ['txt', '盘点状态', 'status'],
+  ['txt', '藏品总登记账具体数量(件)', 'pcsRegister'],
+  ['txt', '相符情况', 'conform'],
+  ['txt', '账物相符(件)', 'pcsConform'],
+  ['txt', '账物不符(件)', 'pcsUnConform'],
+  ['txt', '不符情形', 'unInfo'],
+  ['txt', '不符原因', 'reasonInfo'],
+  ['txt', '备注', 'remark'],
+  ['txt', '最新盘点名称', 'checkName'],
+  ['txt', '盘点时间', 'updateTime'],
+  ['txt', '经办人', 'checkHandler'],
+  ['txt', '负责人', 'checkOwner']
+]
+
 function A3result() {
   const topDomRef = useRef<any>(null)
 
@@ -19,6 +42,16 @@ function A3result() {
       <>
         <AAbtn txt={1} onClick={() => topDomRef.current.clickSearch()} tit='查询' />
         <AAbtn txt={2} onClick={() => topDomRef.current.clickReset()} />
+        <AAbtn
+          txt={1}
+          onClick={() =>
+            topDomRef.current.exportXlsx(
+              columnsTemp,
+              '盘库结果' + dayjs(new Date()).format('YYYY-MM-DD HH:mm')
+            )
+          }
+          tit='导出'
+        />
       </>
     )
   }, [])
@@ -32,30 +65,11 @@ function A3result() {
         ref={topDomRef}
         leftArr={A3topArr}
         rightBtn={rightBtn}
-        waiWidth={190}
+        waiWidth={280}
         sonWidth='9.6%'
         getListAPI={A3_APIgetList}
         tableInfo={tableInfo}
-        columnsTemp={[
-          ['index', '序号', 100],
-          ['txt2', '编号类型', 'numName', 150],
-          ['txt2', '编号', 'num', 150],
-          ['txt2', '名称', 'name', 150],
-          ['txt', '级别', 'level'],
-          ['txt', '类别', 'type'],
-          ['txt', '盘点状态', 'status'],
-          ['txt', '藏品总登记账具体数量(件)', 'pcsRegister'],
-          ['txt', '相符情况', 'conform'],
-          ['txt', '账物相符(件)', 'pcsConform'],
-          ['txt', '账物不符(件)', 'pcsUnConform'],
-          ['txt', '不符情形', 'unInfo'],
-          ['txt', '不符原因', 'reasonInfo'],
-          ['txt', '备注', 'remark'],
-          ['txt', '最新盘点名称', 'checkName'],
-          ['txt', '盘点时间', 'updateTime'],
-          ['txt', '经办人', 'checkHandler'],
-          ['txt', '负责人', 'checkOwner']
-        ]}
+        columnsTemp={columnsTemp}
         tableLastBtn={[
           {
             title: '操作',

+ 62 - 1
src/pages/ZcomPage/TopSearch/index.tsx

@@ -4,6 +4,8 @@ import { Input, Select } from 'antd'
 import { forwardRef, useImperativeHandle } from 'react'
 import { useDispatch } from 'react-redux'
 import MyTable from '@/components/MyTable'
+import ExportJsonExcel from 'js-export-excel'
+import { MessageFu } from '@/utils/message'
 
 type Props = {
   leftArr: any[]
@@ -87,10 +89,69 @@ function TopSearch(
     }, 50)
   }, [])
 
+  // 点击导出
+  const exportXlsx = useCallback(
+    async (data: any, name: string) => {
+      const res = await getListAPI({ ...formDataOldRef.current, pageSize: 999999 }, true)
+      if (res.code === 0) {
+        const list: any[] = res.data.records || []
+        if (list.length <= 0) return MessageFu.warning('当前搜索条件无数据')
+
+        const resList: any[] = []
+        const sheetFilter: string[] = []
+        const sheetHeader: string[] = []
+        const columnWidths: number[] = []
+
+        const typeArr: string[] = []
+
+        data.forEach((v: any) => {
+          typeArr.push(v[0])
+          sheetHeader.push(v[1])
+          if (v[0] === 'index') {
+            columnWidths.push(4)
+            sheetFilter.push('index')
+          } else {
+            columnWidths.push(10)
+            sheetFilter.push(v[2])
+          }
+        })
+
+        list.forEach((v, i) => {
+          let obj: any = {}
+          sheetFilter.forEach((v2, i2) => {
+            if (typeArr[i2] === 'index') obj.index = i + 1
+            else if (['txt', 'txt2'].includes(typeArr[i2])) {
+              obj[v2] = v[v2] === 0 ? 0 : v[v2] || '(空)'
+            }
+          })
+          resList.push(obj)
+        })
+
+        const option = {
+          fileName: name,
+          datas: [
+            {
+              sheetData: resList,
+              sheetName: name,
+              sheetFilter: sheetFilter,
+              sheetHeader: sheetHeader,
+              columnWidths: columnWidths
+            }
+          ]
+        }
+
+        const toExcel = new ExportJsonExcel(option) //new
+        toExcel.saveExcel() //保存
+      }
+    },
+    [getListAPI]
+  )
+
   // 可以让父组件调用子组件的方法
   useImperativeHandle(ref, () => ({
     clickSearch,
-    clickReset
+    clickReset,
+    exportXlsx
   }))
 
   // 页码变化

+ 7 - 5
src/pages/ZgoodsInfo/GI_log/index.module.scss

@@ -1,5 +1,7 @@
-// .GI_log {
-//   :global {
-
-//   }
-// }
+.GI_log {
+  :global {
+    #TopSearch {
+      margin-top: 15px;
+    }
+  }
+}

+ 1 - 1
src/pages/ZgoodsInfo/GI_log/index.tsx

@@ -60,7 +60,7 @@ function GI_log() {
             width: 100,
             render: (item: any) => {
               return (
-                <Button size='small' type='text' onClick={() => setLookId(item.id)}>
+                <Button size='small' type='text' onClick={() => setLookId(item.firmVersionId)}>
                   查看
                 </Button>
               )