Просмотр исходного кода

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

shaogen1995 недель назад: 2
Родитель
Сommit
fce6658f7e

+ 18 - 29
src/pages/Cledger/C1ledger/index.tsx

@@ -3,40 +3,29 @@ import styles from './index.module.scss'
 import http from '@/utils/http'
 import { GoodsType } from '@/pages/Zother/SonGoodsList/data'
 import { selectObj } from '@/utils/dataChange'
-
-// 临时查看数据 正式开发的时候都删掉
-const APITEMP = () => {
-  return http.post('cms/good/ledger/page', { pageSize: 99999 })
-}
+import TableList from '@/pages/Zother/TableList'
+import { useSelector } from 'react-redux'
+import { RootState } from '@/store'
+import { API_getGoodsList } from '@/store/action/Cledger/C1ledger'
+import { baseFormData, topSearch } from '@/pages/Zother/data'
+import { baseTableC } from '@/utils/tableData'
 
 function C1ledger() {
-  const [list, setList] = useState<GoodsType[]>([])
-
-  const tmepFu = useCallback(async () => {
-    const res = await APITEMP()
-    if (res.code === 0) {
-      setList(res.data.records || [])
-    }
-  }, [])
-
-  useEffect(() => {
-    tmepFu()
-  }, [tmepFu])
+  const tableInfo = useSelector((state: RootState) => state.D1register.tableInfo)
 
   return (
     <div className={styles.C1ledger}>
-      <div className='pageTitle'>藏品总账-待开发</div>
-
-      <h1>暂时做一个数据查看信息-总条数-{list.length}</h1>
-
-      <div style={{ height: '90%', overflow: 'auto' }}>
-        {list.map(v => (
-          <div key={v.id}>
-            藏品名称:{v.name}--------------藏品编号:{v.num}-------------藏品入藏状态:{v.status}
-            {selectObj['藏品入藏状态'].find(c => c.value === v.status)?.label}
-          </div>
-        ))}
-      </div>
+      <div className='pageTitle'>藏品总账</div>
+
+      <TableList
+        baseFormData={baseFormData}
+        getListAPI={API_getGoodsList}
+        pageKey='ledger'
+        tableInfo={tableInfo}
+        columnsTemp={baseTableC('总账')}
+        yHeight={585}
+        searchDom={topSearch('总账')}
+      />
     </div>
   )
 }

+ 3 - 2
src/pages/Eculture/E2story/E2edit/index.tsx

@@ -12,7 +12,7 @@ import { Button, Input } from 'antd'
 import { backPageFu } from '@/utils/history'
 import { useParams } from 'react-router-dom'
 import { API_getFileListByIds } from '@/store/action/Cledger/C4file'
-import { API_getGoodsList } from '@/store/action/Cledger/C1ledger'
+import { API_getGoodsLists } from '@/store/action/Cledger/C1ledger'
 import SelectGoods from '@/pages/Zother/SelectGoods'
 import { sgBaseFormDataGood, sgTopSelectDomGood } from '@/pages/Zother/SonGoodsList/data'
 
@@ -165,7 +165,7 @@ function E2edit() {
             {showSelectGoods && (
               <SelectGoods
                 myType='藏品'
-                API_getList={API_getGoodsList}
+                API_getList={API_getGoodsLists}
                 closeFu={() => setShowSelectGoods(false)}
                 baseFormData={sgBaseFormDataGood}
                 topSelectDom={sgTopSelectDomGood}
@@ -228,6 +228,7 @@ function E2edit() {
               <Button type='primary' onClick={() => submitFu()}>
                 提交
               </Button>
+
               <MyPopconfirm txtK='取消' onConfirm={() => backPageFu('/story')} />
             </div>
           )}

+ 21 - 3
src/pages/Eculture/E2story/index.tsx

@@ -2,13 +2,15 @@ import React, { useMemo, useCallback } from 'react'
 import styles from './index.module.scss'
 import { useSelector } from 'react-redux'
 import { RootState } from '@/store'
-import { E2_APIgetList } from '@/store/action/Eculture/E2story'
+import { E2_APIgetList, E2_APIdel } from '@/store/action/Eculture/E2story'
+import { MessageFu } from '@/utils/message'
 import TableList from '@/pages/Zother/TableList'
 import { baseFormData } from '@/pages/Zother/data'
 import MyPopconfirm from '@/components/MyPopconfirm'
 import { storyTableC } from '@/utils/tableData'
 import { Button } from 'antd'
 import history from '@/utils/history'
+import { useDispatch } from 'react-redux'
 
 const E2topSearch = [
   {
@@ -35,9 +37,25 @@ const dataExport = () => {
 }
 
 function D1register() {
+  const dispatch = useDispatch()
   // 从仓库拿数据
   const tableInfo = useSelector((state: RootState) => state.E2story.tableInfo)
 
+  const getListFu = useCallback(() => {
+    dispatch(E2_APIgetList(D1baseFormData))
+  }, [dispatch])
+
+  const delFu = useCallback(
+    async (id: string) => {
+      const res = await E2_APIdel(id)
+      if (res.code === 0) {
+        MessageFu.success('删除成功')
+        getListFu()
+      }
+    },
+    [getListFu]
+  )
+
   // 故事管理定制右侧内容
   const storyTableListToprr = ({
     clickSearch,
@@ -79,12 +97,12 @@ function D1register() {
             <Button size='small' type='text' onClick={() => tableBtnFu(item.id, '2')}>
               编辑
             </Button>
-            <MyPopconfirm txtK='删除' onConfirm={() => console.log('del')} />
+            <MyPopconfirm txtK='删除' onConfirm={() => delFu(item.id)} />
           </>
         )
       }
     ]
-  }, [tableBtnFu])
+  }, [delFu, tableBtnFu])
 
   return (
     <div className={styles.E2story}>

+ 1 - 0
src/pages/Zother/SelectGoods/index.tsx

@@ -77,6 +77,7 @@ function SelectGoods({
     if (timeKey === 0) obj.pageSize = 99999
 
     const res = await API_getList(obj)
+    console.log(res)
     if (res.code === 0) {
       let resArr: any[] = res.data.records || []
 

+ 32 - 2
src/store/action/Cledger/C1ledger.ts

@@ -1,4 +1,5 @@
 import http from '@/utils/http'
+import { AppDispatch } from '@/store'
 
 /**
  * 藏品总账-获取藏品详情
@@ -8,12 +9,41 @@ export const API_getGoodsInfo = (id: number) => {
 }
 
 /**
+ * 藏品总账-获取藏品分页列表
+ */
+export const API_getGoodsList = (data: any): any => {
+  return async (dispatch: AppDispatch) => {
+    const res = await http.post(`cms/good/ledger/page`, data)
+    if (res.code === 0) {
+      const obj = {
+        list: res.data.records,
+        total: res.data.total
+      }
+
+      dispatch({ type: 'E2/getList', payload: obj })
+    }
+  }
+}
+
+/**
  * 藏品总账-获取藏品列表
  */
-export const API_getGoodsList = (data: any) => {
+export const API_getGoodsLists = (data: any): any => {
   return http.post(`cms/good/ledger/page`, data)
 }
 
+/**
+ * 藏品-附件-根据藏品Id查询
+ */
+type GetGoodsByGoodIdReq = {
+  moduleId: number
+  moduleName: string
+  type: string
+}
+export const API_getGoodsByGoodId = (data: GetGoodsByGoodIdReq) => {
+  return http.post(`cms/good/ledger/file`, data)
+}
+
 // ----------------故事模块-----------
 /**
  * 故事-新增
@@ -22,7 +52,7 @@ export const guShiAPI_add = (data: any) => {
   return http.post('cms/story/save', data)
 }
 /**
- * 故事-获取列表
+ * 故事-获取列表(完整)
  */
 export const guShiAPI_getList = (goodId: number) => {
   const data: any = {

+ 3 - 2
src/store/action/Eculture/E2story.ts

@@ -21,8 +21,9 @@ export const E2_APIgetList = (data: any): any => {
 /**
  * 故事 - 删除
  */
-export const E2_APIdel = (id: string) => {
-  return http.post(`cms/story/removes/`, { ids: [id] })
+export const E2_APIdel = (id: string | string[]) => {
+  const ids = Array.isArray(id) ? id : [id]
+  return http.post('/cms/story/removes', ids) // 直接传数组
 }
 
 /**

+ 28 - 0
src/store/reducer/Cledger/C1ledger.ts

@@ -0,0 +1,28 @@
+import { Typetable } from '@/pages/Zother/data'
+
+// 初始化状态
+const initState = {
+  // 列表数据
+  tableInfo: {
+    list: [] as Typetable[],
+    total: 0
+  }
+}
+
+// 定义 action 类型
+type Props = {
+  type: 'C1/getList'
+  payload: { list: Typetable[]; total: number }
+}
+
+// reducer
+export default function Reducer(state = initState, action: Props) {
+  switch (action.type) {
+    // 获取列表数据
+    case 'C1/getList':
+      return { ...state, tableInfo: action.payload }
+
+    default:
+      return state
+  }
+}

+ 2 - 0
src/store/reducer/index.ts

@@ -6,6 +6,7 @@ import A0Layout from './layout'
 import B1collect from './Benter/B1collect'
 import B2enterGuan from './Benter/B2enterGuan'
 import B4enterCang from './Benter/B4enterCang'
+import C1ledger from './Cledger/C1ledger'
 import D1register from './Dmanage/D1register'
 import D3writeOff from './Dmanage/D3writeOff'
 import E1tag from './Eculture/E1tag'
@@ -25,6 +26,7 @@ const rootReducer = combineReducers({
   B1collect,
   B2enterGuan,
   B4enterCang,
+  C1ledger,
   D1register,
   D3writeOff,
   E1tag,