From 1656a41f0b1a0182108fe978e83c0b9d0af95f46 Mon Sep 17 00:00:00 2001
From: wstdy <2546291626@qq.com>
Date: Wed, 19 Apr 2023 14:56:51 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8E=A5=E5=85=A5=E7=BB=84=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../TableRender/components/TablePack/index.js |  8 ++-
 src/core/TableRender/index.js                 | 57 ++++++++++++-------
 2 files changed, 43 insertions(+), 22 deletions(-)

diff --git a/src/core/TableRender/components/TablePack/index.js b/src/core/TableRender/components/TablePack/index.js
index 8fb42d5..23ce188 100644
--- a/src/core/TableRender/components/TablePack/index.js
+++ b/src/core/TableRender/components/TablePack/index.js
@@ -3,12 +3,16 @@ import { Table, Tooltip } from 'antd'
 
 const TablePack = (props) => {
 
-  const { } = props
+  const { value, widget } = props
 
   // console.log('props', props)
 
+  if (widget) {
+    console.log('widget', widget)
+  }
+
   return (
-    <div>{JSON.stringify(props)}</div>
+    <div>{value}</div>
   )
 
 }
diff --git a/src/core/TableRender/index.js b/src/core/TableRender/index.js
index daaaca6..954a79e 100644
--- a/src/core/TableRender/index.js
+++ b/src/core/TableRender/index.js
@@ -1,6 +1,6 @@
 import React, { useEffect, useMemo, useState } from 'react'
 import styles from './index.less'
-import { Table, Tooltip } from 'antd'
+import { Table, Tooltip, message } from 'antd'
 import SearchGroup from './components/SearchGroup'
 import TablePack from './components/TablePack'
 import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID, GetTableJson } from '../../apis/process'
@@ -20,7 +20,6 @@ const getFileInfo = (formJson) => {
       }
     }
   }
-  console.log('obj', obj)
   return obj
 }
 
@@ -28,18 +27,18 @@ const TableRender = (props) => {
 
   const userID = window?.globalConfig?.userInfo?.OID || 1
   const { accountName } = props
+  const [params, setParams] = useState({ userID: userID, accountName, direction: 'desc', timeField: '褰曞叆鏃堕棿', pageIndex: 1, pageSize: 100 })
   const [loading, setLoading] = useState(false)
   const [config, setConfig] = useState({ webShowFieldGroup: '', formJson: '' })
   const [dataSource, setDataSource] = useState([])
 
-  const columns = useMemo(() => {
+  const fileColumns = useMemo(() => {
     const { webShowFieldGroup, formJson } = config
     let showField = webShowFieldGroup ? webShowFieldGroup.split(',').filter(v => v) : []
     let json = getFileInfo(formJson)
     let array = []
     showField.forEach(v => {
       array.push({
-        key: new Date().getTime(),
         title: json[v]?.title || v,
         dataIndex: v,
         width: 120,
@@ -55,38 +54,55 @@ const TableRender = (props) => {
     return array
   }, [config])
 
+  const columns = useMemo(() => {
+    return [
+      {
+        title: '搴忓彿',
+        dataIndex: 'r',
+        key: 'r',
+        width: 50,
+        fixed: 'left',
+      },
+      ...fileColumns,
+      {
+        title: '鎿嶄綔',
+        width: 50,
+        fixed: 'right',
+        render: (r) => {
+          return '璇︽儏'
+        }
+      }
+    ]
+  }, [fileColumns])
+
+  const search = (values) => {
+    setParams({ ...params, ...values })
+    getDataSource({ ...params, ...values })
+  }
+
   const getConfig = async () => {
     const { code, data } = await GetAccountConfigInfo(accountName)
-    // if (code === 0) {
-    //   setConfig(data)
-    // }
     const res = await GetTableJson(accountName)
     if (code === 0 && res.code === 0) {
       setConfig({ ...data, formJson: res.data })
     }
   }
 
-  const getDataSource = async (param) => {
+  const getDataSource = async (param = {}) => {
     setLoading(true)
-    let params = {
-      userID: userID,
-      accountName: '',
-      direction: 'desc',
-      timeField: '褰曞叆鏃堕棿',
-      pageIndex: 1,
-      pageSize: 100,
-      ...param,
-    }
-    const { code, data } = await GetAccountPageList(params)
+    const { code, data, msg } = await GetAccountPageList({ ...params, ...param })
     if (code === 0) {
       setDataSource(JSON.parse(data.jsonData))
+    } else {
+      setDataSource([])
+      message.error(msg)
     }
     setLoading(false)
   }
 
   const getData = () => {
     getConfig()
-    getDataSource({ accountName })
+    getDataSource()
   }
 
   useEffect(() => {
@@ -96,11 +112,12 @@ const TableRender = (props) => {
   return (
     <div className={styles.tableRender}>
       <div className={styles.top}>
-        <SearchGroup />
+        <SearchGroup onChange={search} />
       </div>
       <div className={styles.bottom}>
         <Table
           size='small'
+          rowKey='ID'
           bordered
           loading={loading}
           columns={columns}
-- 
2.17.1