添加部门新跳转页面,调整添加学员手机号长度限制

v2
一杯沧海 1 year ago
parent 3844bbc0ca
commit 7666062ea0
  1. 21
      package-lock.json
  2. 1
      package.json
  3. 14
      pnpm-lock.yaml
  4. 1
      src/app.config.ts
  5. 1
      src/pages/manage/addStudent/addStudent.tsx
  6. 6
      src/pages/manage/depAdmin/depAdmin.tsx
  7. 3
      src/pages/manage/department/addDepartment.config.ts
  8. 17
      src/pages/manage/department/addDepartment.scss
  9. 69
      src/pages/manage/department/addDepartment.tsx
  10. 337
      src/pages/preview/search/search/index.tsx

21
package-lock.json generated

@ -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",

@ -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",

@ -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

@ -78,6 +78,7 @@ export default defineAppConfig({
'student/student',
'curriculum/curriculum',
'addStudent/addStudent',
'department/addDepartment',
'depCur/depCur',
'addCur/addCur',
'spotMeeting/spotMeeting',

@ -99,6 +99,7 @@ const AddStudent = () => {
<Input
placeholder='请输入手机号'
name='phone_number'
maxlength={11}
value={userInfo?.phone_number}
onInput={(event) => setUerInfo({...userInfo, phone_number: event.detail.value} as Student)}/>
</View>

@ -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 = () => {
<View className='operation'>
<View className='safeAreaInsetBottom'>
<View onClick={jumpAddStudent}></View>
<View onClick={() => showPop(undefined)}></View>
<View onClick={jumpDepartment}></View>
{
router.params.id && <View onClick={managesSheet}></View>
}

@ -0,0 +1,3 @@
export default definePageConfig({
navigationBarTitleText: '',
})

@ -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;
}

@ -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 (
<View className='bg-white px-2 mt-2'>
<Form className='form' onSubmit={submit}>
<View className='item'>
<View></View>
<Input placeholder='请输入部门名称' name='name' value={departmentInfo?.name}
onBlur={onBlur}/>
</View>
<Button className='add button' formType='submit'>{params.id ? '修改部门' : "添加部门"}</Button>
</Form>
</View>
)
}
export default AddDepartment

@ -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<string[]>([])
// const [hotSearch] = useState<any[]>([])
// 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 (
// <View className="flex flex-column">
// <NavigationBar cancelBack={true} backgroundColor={'#F2F8F6'} text='搜索'/>
// <View className={styles.searchHeader} style={searchStyles}>
// <View className={styles.searchBox}>
// <Image src={search} style={{width: '32rpx', height: '32rpx'}} mode='widthFix'/>
// <Input
// onFocus={() => setFocus(true)}
// onBlur={() => setFocus(false)}
// className={styles.input}
// placeholder={(focus || show) ? '' : "输入关键字搜索"}
// type='text'
// value={value}
// confirmType='search'
// onInput={inpFn}
// onConfirm={searchInput}/>
//
// </View>
// <View className='px-2 text-dark' onClick={cancelSearch}>取消</View>
// {/*{focus || show ? <View className='px-2 text-dark' onClick={cancelSearch}>取消</View> : null}*/}
// </View>
//
//
// {
// recentSearch.length >= 1 && !show &&
// <View className='px-2'>
// <View className={styles.titleBox}>
// <Text className={styles.title}>最近搜索</Text>
// <Image
// src={del}
// mode='widthFix'
// style={{width: '16px', height: '16px', padding: '0 20rpx'}}
// onClick={clearSearch}/>
// </View>
// <View className={styles.contentBox}>
// {
// recentSearch.length > 0 &&
// recentSearch?.map(d =>
// <View className={styles.items}>
// <View onClick={() => getSearchItem(d)} className="font-28">{d}</View>
// </View>)
// }
// </View>
// </View>
// }
// {
// hotSearch.length >= 1 && !show &&
// <>
// <View className={`flex justify-between ${styles.titleBox}`}>
//
// <Text className="font-32 fwb">热门搜索</Text>
// </View>
// <View className="wid100 pt-3 pl-3 box-b">
// <View className="wid100 flex flex-wrap">
// {
// hotSearch.length &&
// hotSearch.map(d =>
// <View className="py-1 px-2 rounded-40 mr-2 mb-2 bg-warning text-white">
// <View onClick={() => {
// getSearchItem(d)
// }} className="font-28">{d}</View>
// </View>)
// }
// </View>
// </View>
// </>
// }
//
// <PageContainer
// onBeforeLeave={cancelSearch}
// onClickOverlay={cancelSearch}
// show={show}
// round
// overlay
// overlayStyle={'background:rgba(0,0,0,0)'}>
// {show && <SearchList name={value} clear={show}/>}
// </PageContainer>
// </View>
// )
// }
// export default Search
import {FC, useState, useMemo, memo, useCallback} from "react";
import {Button, Text, View} from "@tarojs/components";
type Props = {
items: number[]
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<string[]>([])
const [hotSearch] = useState<any[]>([])
const [show, setShow] = useState(false)
const [focus, setFocus] = useState(false)
useDidShow(getRecentSearch)
useEffect(() => {
!show && getRecentSearch()
}, [show])
function inpFn(e) {
setValue(e.detail.value)
}
const Inner:FC<Props> = memo(({items}) =>
{
console.log('子组件渲染')
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 (
<View>
{ items.length &&
items.map(d => <Text key={d} >{d}</Text>)
<View className="flex flex-column">
<NavigationBar cancelBack={true} backgroundColor={'#F2F8F6'} text='搜索'/>
<View className={styles.searchHeader} style={searchStyles}>
<View className={styles.searchBox}>
<Image src={search} style={{width: '32rpx', height: '32rpx'}} mode='widthFix'/>
<Input
onFocus={() => setFocus(true)}
onBlur={() => setFocus(false)}
className={styles.input}
placeholder={(focus || show) ? '' : "输入关键字搜索"}
type='text'
value={value}
confirmType='search'
onInput={inpFn}
onConfirm={searchInput}/>
</View>
<View className='px-2 text-dark' onClick={cancelSearch}></View>
{/*{focus || show ? <View className='px-2 text-dark' onClick={cancelSearch}>取消</View> : null}*/}
</View>
{
recentSearch.length >= 1 && !show &&
<View className='px-2'>
<View className={styles.titleBox}>
<Text className={styles.title}></Text>
<Image
src={del}
mode='widthFix'
style={{width: '16px', height: '16px', padding: '0 20rpx'}}
onClick={clearSearch}/>
</View>
<View className={styles.contentBox}>
{
recentSearch.length > 0 &&
recentSearch?.map(d =>
<View className={styles.items}>
<View onClick={() => getSearchItem(d)} className="font-28">{d}</View>
</View>)
}
</View>
)
})
</View>
}
{
hotSearch.length >= 1 && !show &&
<>
<View className={`flex justify-between ${styles.titleBox}`}>
type Props1 = {
change:(e) => void
<Text className="font-32 fwb"></Text>
</View>
<View className="wid100 pt-3 pl-3 box-b">
<View className="wid100 flex flex-wrap">
{
hotSearch.length &&
hotSearch.map(d =>
<View className="py-1 px-2 rounded-40 mr-2 mb-2 bg-warning text-white">
<View onClick={() => {
getSearchItem(d)
}} className="font-28">{d}</View>
</View>)
}
</View>
</View>
</>
}
const NewInner:FC<Props1> = memo(({change}) => {
console.log('子组件渲染')
return (
<Button onClick={(e) => {change(e)}}>1111111</Button>
)
})
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])
return (
<View style={{marginTop:'200px'}}>
<Text>{b}</Text>
{/*<Button onClick={()=>{setTab(2);setB(b=> b + 1)}}>==2</Button>*/}
{/*<Button onClick={()=>{setTab(3);setB(b=> b + 1)}}>==3</Button>*/}
{/*<Button onClick={()=>{setTab(4);setB(b=> b + 1)}}>==4</Button>*/}
{/*<Button onClick={()=>{setTab(1);setB(b=> b + 1)}}>==1</Button>*/}
{/*<Inner items={mNum}></Inner>*/}
<NewInner change={change}></NewInner>
<PageContainer
onBeforeLeave={cancelSearch}
onClickOverlay={cancelSearch}
show={show}
round
overlay
overlayStyle={'background:rgba(0,0,0,0)'}>
{show && <SearchList name={value} clear={show}/>}
</PageContainer>
</View>
)
}

Loading…
Cancel
Save