|
|
|
@ -1,5 +1,5 @@ |
|
|
|
|
import React, {FC, useCallback, useEffect, useState} from "react"; |
|
|
|
|
import {Checkbox, View} from "@tarojs/components"; |
|
|
|
|
import React, {FC, useCallback, useState} from "react"; |
|
|
|
|
import {Checkbox, Text, View} from "@tarojs/components"; |
|
|
|
|
import Taro from "@tarojs/taro"; |
|
|
|
|
import {curriculum} from "@/api"; |
|
|
|
|
import PopPut from "@/components/popPut/popPut"; |
|
|
|
@ -7,6 +7,8 @@ import folder from "@/static/img/folder.png"; |
|
|
|
|
import MyButton from "@/components/button/MyButton"; |
|
|
|
|
import storageDep from "@/hooks/storageDep"; |
|
|
|
|
import Spin from "@/components/spinner"; |
|
|
|
|
import Empty from "@/components/empty/empty"; |
|
|
|
|
import {Profile} from "@/store"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 选择部门 depIds 是 JSON = number[] |
|
|
|
@ -17,14 +19,23 @@ const SelectDep: FC = () => { |
|
|
|
|
const [ids, setIds] = useState<number[]>([]) |
|
|
|
|
const [deps, setDeps] = useState<Manage[]>([]) |
|
|
|
|
const [enable, setEnable] = useState(true) |
|
|
|
|
const {company} = Profile.useContainer() |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
// useEffect(() => {
|
|
|
|
|
// curriculum.department().then(res => {
|
|
|
|
|
// setDeps(res.data)
|
|
|
|
|
// })
|
|
|
|
|
// setEnable(false)
|
|
|
|
|
// setIds(JSON.parse(params.depIds))
|
|
|
|
|
// }, [])
|
|
|
|
|
|
|
|
|
|
Taro.useDidShow(() => { |
|
|
|
|
curriculum.department().then(res => { |
|
|
|
|
setDeps(res.data) |
|
|
|
|
}) |
|
|
|
|
setEnable(false) |
|
|
|
|
setIds(JSON.parse(params.depIds)) |
|
|
|
|
}, []) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const onChange = useCallback((id: number) => { |
|
|
|
|
const index = ids.indexOf(id) |
|
|
|
@ -49,7 +60,9 @@ const SelectDep: FC = () => { |
|
|
|
|
return ( |
|
|
|
|
<View className='px-2 bg-white'> |
|
|
|
|
<Spin overlay enable={enable}/> |
|
|
|
|
{deps.map((d) => <View className='flex align-center' key={d.id} onClick={() => onChange(d.id)}> |
|
|
|
|
{ |
|
|
|
|
deps.length > 0 ? |
|
|
|
|
deps.map((d) => <View className='flex align-center' key={d.id} onClick={() => onChange(d.id)}> |
|
|
|
|
<Checkbox value={d.id + ''} checked={ids.includes(d.id)} color='#45d4a8'/> |
|
|
|
|
<View style={{flex: 1}}> |
|
|
|
|
<PopPut |
|
|
|
@ -58,11 +71,28 @@ const SelectDep: FC = () => { |
|
|
|
|
chevron |
|
|
|
|
leftImage={folder}/> |
|
|
|
|
</View> |
|
|
|
|
</View>)} |
|
|
|
|
</View>) |
|
|
|
|
: |
|
|
|
|
<> |
|
|
|
|
<Empty name=''/> |
|
|
|
|
<View className="flex flex-column align-center width100"> |
|
|
|
|
<Text className="font-24 mb-3" style={{color:'#ccc'}}>暂无部门点击按钮去添加部门吧</Text> |
|
|
|
|
<MyButton |
|
|
|
|
width={300} |
|
|
|
|
onClick={() => { |
|
|
|
|
Taro.navigateTo({url:`/pages/manage/department/addDepartment?company_id=${company?.id}&parent_id=0&sort=0`}) |
|
|
|
|
}} |
|
|
|
|
>添加部门</MyButton> |
|
|
|
|
</View> |
|
|
|
|
</> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
<View className={'my-3'}> |
|
|
|
|
{ |
|
|
|
|
deps.length > 0 &&<View className={'my-3'}> |
|
|
|
|
<MyButton onClick={ok}>确定</MyButton> |
|
|
|
|
</View> |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</View> |
|
|
|
|
) |
|
|
|
|