|
|
|
@ -1,9 +1,11 @@ |
|
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
|
import {AddDepProps, ManageApi} from "@/api/manage"; |
|
|
|
|
import '../studentAdmin/student.scss' |
|
|
|
|
import {Button, Text, View, PageContainer, Input, Form, CustomWrapper} from "@tarojs/components"; |
|
|
|
|
import {Button, View, PageContainer, Input, Form} from "@tarojs/components"; |
|
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
|
import {Profile} from '@/store' |
|
|
|
|
import './depAdmin.scss' |
|
|
|
|
import PopPut from "@/components/popPut/popPut"; |
|
|
|
|
import folder from '@/static/img/folder.png' |
|
|
|
|
|
|
|
|
|
interface ChangeDataProps { |
|
|
|
|
putCompany: Manage | null |
|
|
|
@ -75,7 +77,7 @@ const ChangeData: FC<ChangeDataProps> = ({putCompany, getDeps}: ChangeDataProps) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const DepAdmin: FC = () => { |
|
|
|
|
const [data, setData] = useState<Manage[]>([]) |
|
|
|
|
const [manages, setManages] = useState<Manage[]>([]) |
|
|
|
|
const [show, setShow] = useState(false) |
|
|
|
|
const [putCompany, setPutCompany] = useState<Manage | null>(null) |
|
|
|
|
|
|
|
|
@ -87,7 +89,7 @@ const DepAdmin: FC = () => { |
|
|
|
|
Object.values(res)?.forEach(d => { |
|
|
|
|
formatData.push(...d) |
|
|
|
|
}) |
|
|
|
|
setData(formatData) |
|
|
|
|
setManages(formatData) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -114,44 +116,56 @@ const DepAdmin: FC = () => { |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function jumpCur(id: number) { |
|
|
|
|
Taro.navigateTo({url: `/pages/manage/depCur/depCur?id=${id}`}) |
|
|
|
|
function managesSheet(item: Manage) { |
|
|
|
|
Taro.showActionSheet({ |
|
|
|
|
itemList: ['查看部门课程', '修改', '删除'], |
|
|
|
|
success({tapIndex}) { |
|
|
|
|
switch (tapIndex) { |
|
|
|
|
case 0: |
|
|
|
|
Taro.navigateTo({url: `/pages/manage/depCur/depCur?id=${item.id}`}) |
|
|
|
|
break |
|
|
|
|
case 1: |
|
|
|
|
showPop(item) |
|
|
|
|
break |
|
|
|
|
case 2: |
|
|
|
|
del(item.name, item.id) |
|
|
|
|
break |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
getData() |
|
|
|
|
}, []) |
|
|
|
|
function jumpAddStudent() { |
|
|
|
|
Taro.navigateTo({url: '/pages/manage/addStudent/addStudent'}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Taro.useDidShow(getData) |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<CustomWrapper> |
|
|
|
|
<Profile.Provider> |
|
|
|
|
{data.map(d => ( |
|
|
|
|
<View className='bg-white user' key={d.id}> |
|
|
|
|
<View className='flex mt-3 header p-2 justify-between'> |
|
|
|
|
<View className='flex'> |
|
|
|
|
<Text>{d.id}:</Text> |
|
|
|
|
<View className='font-weight'>{d.name}</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
<View className='flex justify-between p-2 operation'> |
|
|
|
|
<View onClick={() => showPop(d)}>修改</View> |
|
|
|
|
<View onClick={() => jumpCur(d.id)}>课程</View> |
|
|
|
|
<View className='text-danger' onClick={() => del(d.name, d.id)}>删除</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
))} |
|
|
|
|
|
|
|
|
|
<View className='mt-3 text-center'>- 暂无更多数据 -</View> |
|
|
|
|
|
|
|
|
|
<Button className='add' onClick={() => showPop(null)}>新建部门</Button> |
|
|
|
|
|
|
|
|
|
<PageContainer show={show} round onAfterLeave={() => setShow(false)}> |
|
|
|
|
<View className='h-4'> |
|
|
|
|
{show && <ChangeData getDeps={getData} putCompany={putCompany}/>} |
|
|
|
|
</View> |
|
|
|
|
</PageContainer> |
|
|
|
|
</Profile.Provider> |
|
|
|
|
</CustomWrapper> |
|
|
|
|
<Profile.Provider> |
|
|
|
|
<View> |
|
|
|
|
{ |
|
|
|
|
manages.map(d => <PopPut |
|
|
|
|
key={d.id} |
|
|
|
|
title={d.name} |
|
|
|
|
chevron |
|
|
|
|
onClick={() => managesSheet(d)} |
|
|
|
|
leftImage={folder} |
|
|
|
|
/>) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<View className='operation'> |
|
|
|
|
<View onClick={jumpAddStudent}>添加学员</View> |
|
|
|
|
<View onClick={() => showPop(null)}>添加部门</View> |
|
|
|
|
</View> |
|
|
|
|
</View> |
|
|
|
|
|
|
|
|
|
<PageContainer show={show} round onAfterLeave={() => setShow(false)}> |
|
|
|
|
<View className='h-4'> |
|
|
|
|
{show && <ChangeData getDeps={getData} putCompany={putCompany}/>} |
|
|
|
|
</View> |
|
|
|
|
</PageContainer> |
|
|
|
|
</Profile.Provider> |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|