From 7666062ea04403dd56f9bea083ad41ccdd461636 Mon Sep 17 00:00:00 2001 From: sunlizhou <296190577@qq.com> Date: Fri, 13 Oct 2023 11:27:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=83=A8=E9=97=A8=E6=96=B0?= =?UTF-8?q?=E8=B7=B3=E8=BD=AC=E9=A1=B5=E9=9D=A2=EF=BC=8C=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AD=A6=E5=91=98=E6=89=8B=E6=9C=BA=E5=8F=B7?= =?UTF-8?q?=E9=95=BF=E5=BA=A6=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 21 ++ package.json | 1 + pnpm-lock.yaml | 14 +- src/app.config.ts | 1 + src/pages/manage/addStudent/addStudent.tsx | 1 + src/pages/manage/depAdmin/depAdmin.tsx | 6 +- .../manage/department/addDepartment.config.ts | 3 + .../manage/department/addDepartment.scss | 17 + src/pages/manage/department/addDepartment.tsx | 69 ++++ src/pages/preview/search/search/index.tsx | 343 ++++++++---------- 10 files changed, 275 insertions(+), 201 deletions(-) create mode 100644 src/pages/manage/department/addDepartment.config.ts create mode 100644 src/pages/manage/department/addDepartment.scss create mode 100644 src/pages/manage/department/addDepartment.tsx diff --git a/package-lock.json b/package-lock.json index 3aefb3f..d0f8c3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,6 +26,7 @@ "@tarojs/taro": "3.6.8", "dayjs": "^1.11.9", "marked": "^7.0.4", + "pnpm": "^8.9.0", "react": "^18.0.0", "react-dom": "^18.0.0", "react-refresh": "^0.11.0", @@ -19271,6 +19272,21 @@ "semver-compare": "^1.0.0" } }, + "node_modules/pnpm": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/pnpm/-/pnpm-8.9.0.tgz", + "integrity": "sha512-74hZk44fBTe5/PAwkEQxE5Lzs4s0QXbmzU/e4hsiVSSwrCobCK4q4t3Vs/9LjKSW1neOlQ8+fJ9VW4EyWYJEHA==", + "bin": { + "pnpm": "bin/pnpm.cjs", + "pnpx": "bin/pnpx.cjs" + }, + "engines": { + "node": ">=16.14" + }, + "funding": { + "url": "https://opencollective.com/pnpm" + } + }, "node_modules/portfinder": { "version": "1.0.32", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", @@ -39683,6 +39699,11 @@ "semver-compare": "^1.0.0" } }, + "pnpm": { + "version": "8.9.0", + "resolved": "https://registry.npmjs.org/pnpm/-/pnpm-8.9.0.tgz", + "integrity": "sha512-74hZk44fBTe5/PAwkEQxE5Lzs4s0QXbmzU/e4hsiVSSwrCobCK4q4t3Vs/9LjKSW1neOlQ8+fJ9VW4EyWYJEHA==" + }, "portfinder": { "version": "1.0.32", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", diff --git a/package.json b/package.json index c221015..7f97d92 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,7 @@ "@tarojs/taro": "3.6.8", "dayjs": "^1.11.9", "marked": "^7.0.4", + "pnpm": "^8.9.0", "react": "^18.0.0", "react-dom": "^18.0.0", "react-refresh": "^0.11.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2b130cf..d5b03f1 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: '6.1' +lockfileVersion: '6.0' settings: autoInstallPeers: true @@ -56,6 +56,9 @@ dependencies: marked: specifier: ^7.0.4 version: 7.0.4 + pnpm: + specifier: ^8.9.0 + version: 8.9.0 react: specifier: ^18.0.0 version: 18.0.0 @@ -716,6 +719,7 @@ packages: /@babel/plugin-proposal-numeric-separator@7.18.6(@babel/core@7.22.5): resolution: {integrity: sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -727,6 +731,7 @@ packages: /@babel/plugin-proposal-numeric-separator@7.18.6(@babel/core@7.8.0): resolution: {integrity: sha512-ozlZFogPqoLm8WBr5Z8UckIoE4YQ5KESVcNudyXOR8uqIkliTEgJ3RoketfG6pmzLdeZF0H/wjE9/cCEitBl7Q==} engines: {node: '>=6.9.0'} + deprecated: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead. peerDependencies: '@babel/core': ^7.0.0-0 dependencies: @@ -11623,6 +11628,12 @@ packages: semver-compare: 1.0.0 dev: true + /pnpm@8.9.0: + resolution: {integrity: sha512-74hZk44fBTe5/PAwkEQxE5Lzs4s0QXbmzU/e4hsiVSSwrCobCK4q4t3Vs/9LjKSW1neOlQ8+fJ9VW4EyWYJEHA==} + engines: {node: '>=16.14'} + hasBin: true + dev: false + /portfinder@1.0.32: resolution: {integrity: sha512-on2ZJVVDXRADWE6jnQaX0ioEylzgBpQk8r55NE4wjXW1ZxO+BgDlY6DXwj20i0V8eB4SenDQ00WEaxfiIQPcxg==} engines: {node: '>= 0.12.0'} @@ -12192,6 +12203,7 @@ packages: /prr@1.0.1: resolution: {integrity: sha512-yPw4Sng1gWghHQWj0B3ZggWUm4qVbPwPFcRG8KyxiU7J2OHFSoEHKS+EZ3fv5l1t9CyCiop6l/ZYeWbrgoQejw==} + requiresBuild: true dev: true optional: true diff --git a/src/app.config.ts b/src/app.config.ts index c8a074f..a9ee822 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -78,6 +78,7 @@ export default defineAppConfig({ 'student/student', 'curriculum/curriculum', 'addStudent/addStudent', + 'department/addDepartment', 'depCur/depCur', 'addCur/addCur', 'spotMeeting/spotMeeting', diff --git a/src/pages/manage/addStudent/addStudent.tsx b/src/pages/manage/addStudent/addStudent.tsx index 44728ef..bea6d35 100644 --- a/src/pages/manage/addStudent/addStudent.tsx +++ b/src/pages/manage/addStudent/addStudent.tsx @@ -99,6 +99,7 @@ const AddStudent = () => { setUerInfo({...userInfo, phone_number: event.detail.value} as Student)}/> diff --git a/src/pages/manage/depAdmin/depAdmin.tsx b/src/pages/manage/depAdmin/depAdmin.tsx index b9b2d0f..d4867f8 100644 --- a/src/pages/manage/depAdmin/depAdmin.tsx +++ b/src/pages/manage/depAdmin/depAdmin.tsx @@ -100,6 +100,10 @@ const DepAdmin: FC = () => { Taro.navigateTo({url: '/pages/manage/addStudent/addStudent'}) } + function jumpDepartment(){ + Taro.navigateTo({url:`/pages/manage/department/addDepartment?company_id=${company?.id}&parent_id=${Number(router.params.dep_id) || 0}&sort=${manages.length}`}) + } + const addDep = useCallback(async () => { if (!depName) { Taro.showToast({title: '请填写部门名称!', icon: 'error'}) @@ -165,7 +169,7 @@ const DepAdmin: FC = () => { 添加学员 - showPop(undefined)}>添加部门 + 添加部门 { router.params.id && 更多操作 } diff --git a/src/pages/manage/department/addDepartment.config.ts b/src/pages/manage/department/addDepartment.config.ts new file mode 100644 index 0000000..457d7f4 --- /dev/null +++ b/src/pages/manage/department/addDepartment.config.ts @@ -0,0 +1,3 @@ +export default definePageConfig({ + navigationBarTitleText: '', +}) diff --git a/src/pages/manage/department/addDepartment.scss b/src/pages/manage/department/addDepartment.scss new file mode 100644 index 0000000..01ffd9a --- /dev/null +++ b/src/pages/manage/department/addDepartment.scss @@ -0,0 +1,17 @@ +.dep { + background: #ddd; + padding: 5px 15px; + border-radius: 3px; +} + +.depSelected { + background: #9ee0a3; + color: #3f6942; +} + +.add { + //position: fixed; + width: 710rpx; + margin-top: 30px; + border: none !important; +} diff --git a/src/pages/manage/department/addDepartment.tsx b/src/pages/manage/department/addDepartment.tsx new file mode 100644 index 0000000..49ce074 --- /dev/null +++ b/src/pages/manage/department/addDepartment.tsx @@ -0,0 +1,69 @@ +import {Button, Form, Input, View} from "@tarojs/components"; +import {useEffect, useState} from "react"; +import {ManageApi} from "@/api/manage"; +import Taro from "@tarojs/taro"; +import './addDepartment.scss'; +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:'添加部门' }) + if (params.id) { + Taro.setNavigationBarTitle({ title:'修改部门' }) + } + }, []) + + + async function submit(e) { + const value: {name: string} = e.detail.value + for (const [_, val] of Object.entries(value)) { + if (!val) { + Taro.showToast({title: "请填写部门名称", icon: 'error'}) + return + } + } + Taro.showLoading() + try { + if (params.id) { + await ManageApi.putDep(params.id, departmentInfo!.name) + } else { + await ManageApi.addDep({ + name: departmentInfo!.name, + parent_id: Number(params.parent_id), + company_id: Number(params.company_id), + sort: Number(params.sort), + }) + } + Taro.hideLoading() + Taro.showToast({title: "添加成功", icon: 'success'}) + setTimeout(() => { + Taro.navigateBack() + }, 500) + } catch (e) { + } + Taro.hideLoading() + } + + function onBlur(e){ + setDepartmentInfo(p => ({...p,name:e.detail.value})) + } + + return ( + +
+ + 部门 + + + +
+
+ ) +} + +export default AddDepartment diff --git a/src/pages/preview/search/search/index.tsx b/src/pages/preview/search/search/index.tsx index a40b657..b6e87bd 100644 --- a/src/pages/preview/search/search/index.tsx +++ b/src/pages/preview/search/search/index.tsx @@ -1,206 +1,151 @@ -// import {Input, View, Text, PageContainer, Image} from "@tarojs/components"; -// import {FC, useEffect, useMemo, useState} from "react"; -// import styles from './index.module.scss' -// import Taro from "@tarojs/taro"; -// import {useDidShow} from '@tarojs/taro' -// import SearchList from './components/list' -// import NavigationBar from "@/components/navigationBar/navigationBar"; -// import search from '@/static/img/search.png' -// import del from '@/static/img/del.png' -// -// -// const Search: FC = () => { -// const [value, setValue] = useState('') -// const [recentSearch, setRecentSearch] = useState([]) -// const [hotSearch] = useState([]) -// const [show, setShow] = useState(false) -// const [focus, setFocus] = useState(false) -// -// -// useDidShow(getRecentSearch) -// -// useEffect(() => { -// !show && getRecentSearch() -// }, [show]) -// -// function inpFn(e) { -// setValue(e.detail.value) -// } -// -// function clearSearch() { -// Taro.removeStorageSync('recentSearch') -// getRecentSearch() -// Taro.showToast({title: '删除成功'}) -// } -// -// function getRecentSearch() { -// setRecentSearch(Taro.getStorageSync('recentSearch')) -// } -// -// function getSearchItem(value) { -// setValue(value) -// setShow(true) -// } -// -// function searchInput() { -// if (value === "") return; -// getSearchItem(value) -// //记录最近搜索 -// let recentSearch = Taro.getStorageSync('recentSearch') || []; -// recentSearch.unshift(value); -// Taro.setStorageSync('recentSearch', [...new Set(recentSearch)]) -// } -// -// function cancelSearch(){ -// setValue('') -// setShow(false) -// setFocus(false) -// Taro.navigateBack() -// } -// -// -// const searchStyles = useMemo((): React.CSSProperties | undefined => { -// if (focus || show) { -// return { -// // transform: "translateY(-43px)", -// // width: "100%", -// } -// } -// }, [focus, show]) -// -// -// return ( -// -// -// -// -// -// setFocus(true)} -// onBlur={() => setFocus(false)} -// className={styles.input} -// placeholder={(focus || show) ? '' : "输入关键字搜索"} -// type='text' -// value={value} -// confirmType='search' -// onInput={inpFn} -// onConfirm={searchInput}/> -// -// -// 取消 -// {/*{focus || show ? 取消 : null}*/} -// -// -// -// { -// recentSearch.length >= 1 && !show && -// -// -// 最近搜索 -// -// -// -// { -// recentSearch.length > 0 && -// recentSearch?.map(d => -// -// getSearchItem(d)} className="font-28">{d} -// ) -// } -// -// -// } -// { -// hotSearch.length >= 1 && !show && -// <> -// -// -// 热门搜索 -// -// -// -// { -// hotSearch.length && -// hotSearch.map(d => -// -// { -// getSearchItem(d) -// }} className="font-28">{d} -// ) -// } -// -// -// -// } -// -// -// {show && } -// -// -// ) -// } -// export default Search - -import {FC, useState, useMemo, memo, useCallback} from "react"; -import {Button, Text, View} from "@tarojs/components"; - - -type Props = { - items: number[] -} -const Inner:FC = memo(({items}) => -{ - console.log('子组件渲染') - return ( - - { items.length && - items.map(d => {d}) - } - - ) -}) +import {Input, View, Text, PageContainer, Image} from "@tarojs/components"; +import {FC, useEffect, useMemo, useState} from "react"; +import styles from './index.module.scss' +import Taro from "@tarojs/taro"; +import {useDidShow} from '@tarojs/taro' +import SearchList from './components/list' +import NavigationBar from "@/components/navigationBar/navigationBar"; +import search from '@/static/img/search.png' +import del from '@/static/img/del.png' -type Props1 = { - change:(e) => void -} -const NewInner:FC = memo(({change}) => { - console.log('子组件渲染') - return ( - - ) -}) const Search: FC = () => { - const [b,setB]=useState(1) - const [todos]=useState([1,2,3,4,5]) - const [tab,setTab] = useState(1) - console.log('父组件渲染') - const mNum = useMemo(() => todos.filter(d => d !== tab),[todos,tab]) - - const change = useCallback((e:any) => { - console.log(e) - console.log(b,'b') - setB( b + 1) - },[b]) + const [value, setValue] = useState('') + const [recentSearch, setRecentSearch] = useState([]) + const [hotSearch] = useState([]) + const [show, setShow] = useState(false) + const [focus, setFocus] = useState(false) + + + useDidShow(getRecentSearch) + + useEffect(() => { + !show && getRecentSearch() + }, [show]) + + function inpFn(e) { + setValue(e.detail.value) + } + + function clearSearch() { + Taro.removeStorageSync('recentSearch') + getRecentSearch() + Taro.showToast({title: '删除成功'}) + } + + function getRecentSearch() { + setRecentSearch(Taro.getStorageSync('recentSearch')) + } + + function getSearchItem(value) { + setValue(value) + setShow(true) + } + + function searchInput() { + if (value === "") return; + getSearchItem(value) + //记录最近搜索 + let recentSearch = Taro.getStorageSync('recentSearch') || []; + recentSearch.unshift(value); + Taro.setStorageSync('recentSearch', [...new Set(recentSearch)]) + } + + function cancelSearch(){ + setValue('') + setShow(false) + setFocus(false) + Taro.navigateBack() + } + + + const searchStyles = useMemo((): React.CSSProperties | undefined => { + if (focus || show) { + return { + // transform: "translateY(-43px)", + // width: "100%", + } + } + }, [focus, show]) + + return ( - - {b} - {/**/} - {/**/} - {/**/} - {/**/} - {/**/} - + + + + + + setFocus(true)} + onBlur={() => setFocus(false)} + className={styles.input} + placeholder={(focus || show) ? '' : "输入关键字搜索"} + type='text' + value={value} + confirmType='search' + onInput={inpFn} + onConfirm={searchInput}/> + + + 取消 + {/*{focus || show ? 取消 : null}*/} + + + + { + recentSearch.length >= 1 && !show && + + + 最近搜索 + + + + { + recentSearch.length > 0 && + recentSearch?.map(d => + + getSearchItem(d)} className="font-28">{d} + ) + } + + + } + { + hotSearch.length >= 1 && !show && + <> + + + 热门搜索 + + + + { + hotSearch.length && + hotSearch.map(d => + + { + getSearchItem(d) + }} className="font-28">{d} + ) + } + + + + } + + + {show && } + ) }