|
|
@@ -0,0 +1,102 @@
|
|
|
+import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
+import styles from './index.module.scss'
|
|
|
+import { Input, Select } from 'antd'
|
|
|
+import { useDispatch, useSelector } from 'react-redux'
|
|
|
+import { A3fromDataBase, A3Select, A3tableType } from './data'
|
|
|
+import { A3_APIdel, A3_APIgetList } from '@/store/action/A3answers'
|
|
|
+import { RootState } from '@/store'
|
|
|
+import { MessageFu } from '@/utils/message'
|
|
|
+import MyPopconfirm from '@/components/MyPopconfirm'
|
|
|
+import MyTable from '@/components/MyTable'
|
|
|
+import { A3tableC } from '@/utils/tableData'
|
|
|
+function A3answers() {
|
|
|
+ const dispatch = useDispatch()
|
|
|
+ const [formData, setFormData] = useState(A3fromDataBase)
|
|
|
+
|
|
|
+ const getListFu = useCallback(() => {
|
|
|
+ dispatch(A3_APIgetList(formData))
|
|
|
+ }, [dispatch, formData])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ getListFu()
|
|
|
+ }, [getListFu])
|
|
|
+
|
|
|
+ // 输入框改变
|
|
|
+ const timeRef = useRef(-1)
|
|
|
+ const txtChangeFu = useCallback(
|
|
|
+ (e: React.ChangeEvent<HTMLInputElement>, key: 'searchKey') => {
|
|
|
+ clearTimeout(timeRef.current)
|
|
|
+ timeRef.current = window.setTimeout(() => {
|
|
|
+ setFormData({
|
|
|
+ ...formData,
|
|
|
+ [key]: e.target.value,
|
|
|
+ pageNum: 1
|
|
|
+ })
|
|
|
+ }, 500)
|
|
|
+ },
|
|
|
+ [formData]
|
|
|
+ )
|
|
|
+
|
|
|
+ // 从仓库拿数据
|
|
|
+ const tableInfo = useSelector((state: RootState) => state.A3answers.tableInfo)
|
|
|
+ // 点击删除
|
|
|
+ const delTableFu = useCallback(
|
|
|
+ async (id: number) => {
|
|
|
+ const res: any = await A3_APIdel([id])
|
|
|
+ if (res.code === 0) {
|
|
|
+ MessageFu.success('删除成功!')
|
|
|
+ getListFu()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ [getListFu]
|
|
|
+ )
|
|
|
+
|
|
|
+ const tableLastBtn = useMemo(() => {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ render: (item: A3tableType) => (
|
|
|
+ <MyPopconfirm txtK='删除' onConfirm={() => delTableFu(item.id)} />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }, [delTableFu])
|
|
|
+
|
|
|
+ return (
|
|
|
+ <div className={styles.A3answers}>
|
|
|
+ <div className='A3top'>
|
|
|
+ <Select
|
|
|
+ allowClear
|
|
|
+ placeholder='反馈类型'
|
|
|
+ style={{ width: 300 }}
|
|
|
+ options={A3Select}
|
|
|
+ value={formData.type || null}
|
|
|
+ onChange={e => setFormData({ ...formData, type: e, pageNum: 1 })}
|
|
|
+ />
|
|
|
+  
|
|
|
+ <Input
|
|
|
+ placeholder='请输入问题或回答'
|
|
|
+ maxLength={50}
|
|
|
+ showCount
|
|
|
+ allowClear
|
|
|
+ onChange={e => txtChangeFu(e, 'searchKey')}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <MyTable
|
|
|
+ yHeight={620}
|
|
|
+ list={tableInfo.list}
|
|
|
+ columnsTemp={A3tableC}
|
|
|
+ lastBtn={tableLastBtn}
|
|
|
+ pageNum={formData.pageNum}
|
|
|
+ pageSize={formData.pageSize}
|
|
|
+ total={tableInfo.total}
|
|
|
+ onChange={(pageNum, pageSize) => setFormData({ ...formData, pageNum, pageSize })}
|
|
|
+ // widthSet={{ answer: 300, suggest: 300 }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+const MemoA3answers = React.memo(A3answers)
|
|
|
+
|
|
|
+export default MemoA3answers
|