diff --git a/src/pages/manage/addStudent/addStudent.tsx b/src/pages/manage/addStudent/addStudent.tsx index bea6d35..8266a8a 100644 --- a/src/pages/manage/addStudent/addStudent.tsx +++ b/src/pages/manage/addStudent/addStudent.tsx @@ -73,13 +73,14 @@ const AddStudent = () => { }, [depIds]) useEffect(() => { - getDepartment() if (params.id) { getUserInfo() } }, []) - Taro.useDidShow(() => { + + Taro.useDidShow( async() => { + await getDepartment() const newDepIds = storageDep.get() setDepIds(newDepIds) }) diff --git a/src/pages/manage/courseAdmin/components/search.tsx b/src/pages/manage/courseAdmin/components/search.tsx index 7dbaf38..aa8dddc 100644 --- a/src/pages/manage/courseAdmin/components/search.tsx +++ b/src/pages/manage/courseAdmin/components/search.tsx @@ -1,4 +1,4 @@ -import {FC, useCallback, useEffect, useState} from "react"; +import {FC, useCallback, useState} from "react"; import {Image, Input, Radio, Text, View} from "@tarojs/components"; import styles from "../courseAdmin.module.scss"; import Icon from "@/components/icon"; @@ -7,9 +7,9 @@ import CustomPageContainer from "@/components/custom-page-container/custom-page- import Empty from "@/components/empty/empty"; import MyButton from "@/components/button/MyButton"; import downArrow from '@/static/img/downArrow.png' -import downArrowKey from '@/static/img/downArrowKey.png' import omit from '@/static/img/omit.png' import Taro from "@tarojs/taro"; +import {Profile} from "@/store"; interface Props { param: CourseAllParam @@ -23,8 +23,13 @@ export const Search: FC = ({param, setParam, total, setBatch}) => { const [deps, setDeps] = useState([]) const [depId, setDepId] = useState(param.dep_id) const [title, setTitle] = useState(param.title) + const {company} = Profile.useContainer() + Taro.useDidShow(() => { + getDepList() + }) + function onBatch() { Taro.showActionSheet({ itemList: ['批量添加部门'], @@ -67,9 +72,8 @@ export const Search: FC = ({param, setParam, total, setBatch}) => { } }, [depId]) - useEffect(() => { - getDepList() - }, []) + + return ( <> @@ -150,7 +154,24 @@ export const Search: FC = ({param, setParam, total, setBatch}) => { - : } + : + <> + + + 暂无部门点击按钮去添加部门吧 + { + Taro.navigateTo({url:`/pages/manage/department/addDepartment?company_id=${company?.id}&parent_id=0&sort=0`}) + setTimeout(() => { + setShow(false) + },1000) + }} + >添加部门 + + + + } diff --git a/src/pages/manage/courseAdmin/courseAdmin.tsx b/src/pages/manage/courseAdmin/courseAdmin.tsx index d81175c..80b6dd2 100644 --- a/src/pages/manage/courseAdmin/courseAdmin.tsx +++ b/src/pages/manage/courseAdmin/courseAdmin.tsx @@ -24,6 +24,7 @@ const CourseAdmin: FC = () => { dep_id: 0 }) + /** *@param replace 替换 */ diff --git a/src/pages/manage/depAdmin/depAdmin.scss b/src/pages/manage/depAdmin/depAdmin.scss index 0a3ddd5..df1ec89 100644 --- a/src/pages/manage/depAdmin/depAdmin.scss +++ b/src/pages/manage/depAdmin/depAdmin.scss @@ -17,8 +17,6 @@ .safeAreaInsetBottom { height: 100rpx; - align-items: center; - justify-content: space-around; padding-bottom: env(safe-area-inset-bottom); display: flex; } diff --git a/src/pages/manage/depAdmin/depAdmin.tsx b/src/pages/manage/depAdmin/depAdmin.tsx index d4867f8..1f1e095 100644 --- a/src/pages/manage/depAdmin/depAdmin.tsx +++ b/src/pages/manage/depAdmin/depAdmin.tsx @@ -90,8 +90,7 @@ const DepAdmin: FC = () => { break } }, - fail() { - } + fail(){} }) } @@ -168,10 +167,10 @@ const DepAdmin: FC = () => { - 添加学员 - 添加部门 + 添加学员 + 添加部门 { - router.params.id && 更多操作 + router.params.id && 更多操作 } diff --git a/src/pages/manage/department/addDepartment.tsx b/src/pages/manage/department/addDepartment.tsx index 49ce074..4668ca6 100644 --- a/src/pages/manage/department/addDepartment.tsx +++ b/src/pages/manage/department/addDepartment.tsx @@ -8,7 +8,6 @@ import {getCurrentInstance} from "@tarojs/runtime"; const AddDepartment = () => { const [departmentInfo, setDepartmentInfo] = useState<{ name: string } | null>(null) const params = getCurrentInstance()?.router?.params as { id?: string;parent_id?: string;sort?: string;company_id?:string } - console.log(params) useEffect(() => { Taro.setNavigationBarTitle({ title:'添加部门' }) @@ -22,7 +21,7 @@ const AddDepartment = () => { const value: {name: string} = e.detail.value for (const [_, val] of Object.entries(value)) { if (!val) { - Taro.showToast({title: "请填写部门名称", icon: 'error'}) + Taro.showToast({title: "请填写部门名称a", icon: 'error'}) return } } diff --git a/src/pages/manage/selectDep/selectDep.tsx b/src/pages/manage/selectDep/selectDep.tsx index 8a34de9..cd8551c 100644 --- a/src/pages/manage/selectDep/selectDep.tsx +++ b/src/pages/manage/selectDep/selectDep.tsx @@ -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([]) const [deps, setDeps] = useState([]) 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,20 +60,39 @@ const SelectDep: FC = () => { return ( - {deps.map((d) => onChange(d.id)}> - - - + { + deps.length > 0 ? + deps.map((d) => onChange(d.id)}> + + + + + ) + : + <> + + + 暂无部门点击按钮去添加部门吧 + { + Taro.navigateTo({url:`/pages/manage/department/addDepartment?company_id=${company?.id}&parent_id=0&sort=0`}) + }} + >添加部门 + + + } + + { + deps.length > 0 && + 确定 - )} + } - - 确定 - ) diff --git a/src/pages/my/components/header/header.tsx b/src/pages/my/components/header/header.tsx index d3bbc03..75d695e 100644 --- a/src/pages/my/components/header/header.tsx +++ b/src/pages/my/components/header/header.tsx @@ -29,7 +29,7 @@ const Header: FC = ({companyList, showCompany}) => { {token ? user?.name ?? '匿名' : '请登录'} - {token ? company?.name : '登录解锁更多功能哦'} + {token ? company?.company_name : '登录解锁更多功能哦'} {showChoose && } diff --git a/src/pages/my/my.tsx b/src/pages/my/my.tsx index 283418a..9a8c050 100644 --- a/src/pages/my/my.tsx +++ b/src/pages/my/my.tsx @@ -160,7 +160,7 @@ const My: FC = () => { - {d.name} + {d.company_name} diff --git a/src/pages/preview/brand/info/info.tsx b/src/pages/preview/brand/info/info.tsx index 91eee7a..7e3fa8d 100644 --- a/src/pages/preview/brand/info/info.tsx +++ b/src/pages/preview/brand/info/info.tsx @@ -96,7 +96,7 @@ const BrandInfo: FC = () => { { (brandInfo?.brand_album?.length || 0) > 0 && brandInfo?.brand_album?.split(',').map((d) => - + ) }