部门样式

main
king 1 year ago
parent 5b8d492e31
commit ca0562a0a1
  1. 2
      src/components/custom-page-container/custom-page-container.module.scss
  2. 8
      src/components/custom-page-container/custom-page-container.tsx
  3. 4
      src/components/popPut/popPut.tsx
  4. 7
      src/components/showModel/showModel.module.scss
  5. 28
      src/components/showModel/showModel.tsx
  6. 2
      src/components/topic/shortAnswer.tsx
  7. 9
      src/pages/manage/depAdmin/depAdmin.scss
  8. 147
      src/pages/manage/depAdmin/depAdmin.tsx
  9. 10
      src/pages/manage/offline/offline.module.scss
  10. 31
      src/pages/manage/offline/offline.tsx
  11. 2
      src/static/css/module.scss

@ -11,7 +11,7 @@
} }
.overlay { .overlay {
background: rgba(#000, .5); background: rgba(#000, .75);
position: absolute; position: absolute;
top: 0; top: 0;
bottom: 0; bottom: 0;

@ -26,15 +26,17 @@ const PageContainerInner: FC<PageContainerProps> = (props) => {
switch (props.position) { switch (props.position) {
case "top": case "top":
style.borderRadius = '0 0 30px 30px' style.borderRadius = '0 0 10px 10px'
style.top = 0 style.top = 0
break break
case 'bottom': case 'bottom':
style.borderRadius = '30px 30px 0 0' style.borderRadius = '10px 10px 0 0'
style.bottom = 0 style.bottom = 0
break break
case 'center': case 'center':
style.borderRadius = '30px' style.width = '90%'
style.borderRadius = '10px'
style.padding = '0'
break break
} }

@ -47,13 +47,13 @@ const PopPut: FC<Props> = ({title, chevron, content, image, isProp, children, sh
<> <>
<View className='card' onClick={click} style={style()}> <View className='card' onClick={click} style={style()}>
<View className='flex align-center'> <View className='flex align-center'>
{opt.leftImage && <Image src={opt.leftImage} className='mr-3' mode='aspectFit'/>} {opt.leftImage && <Image src={opt.leftImage} className='mr-3 image' mode='aspectFit'/>}
<View>{title}</View> <View>{title}</View>
</View> </View>
<View className='card-content'> <View className='card-content'>
<Text>{content}</Text> <Text>{content}</Text>
{!chevron && <Icon name='chevron-right'/>} {!chevron && <Icon name='chevron-right'/>}
{image && <Image src={image} mode='scaleToFill'/>} {image && <Image src={image} mode='scaleToFill' className='image'/>}
</View> </View>
</View> </View>
{ {

@ -0,0 +1,7 @@
.operation {
display: flex;
justify-content: space-around;
padding: 20px 0;
width: 100%;
border-top: 1px solid #eee;
}

@ -0,0 +1,28 @@
import {FC, ReactNode} from "react";
import CustomPageContainer from "@/components/custom-page-container/custom-page-container";
import {View} from "@tarojs/components";
import styles from './showModel.module.scss'
interface Props {
show: boolean
onClickOverlay: () => void
children?: ReactNode
okText?: string
title?: string
onOk?: () => void
}
const ShowModel: FC<Props> = (pros) => {
return (
<CustomPageContainer position='center' round show={pros.show} onClickOverlay={pros.onClickOverlay}>
<View className='text-center mt-2'>{pros.title}</View>
{pros.children}
<View className={styles.operation}>
<View className={styles.cancel} onClick={pros.onClickOverlay}></View>
<View onClick={pros.onOk}>{pros.okText || '确定'}</View>
</View>
</CustomPageContainer>
)
}
export default ShowModel

@ -45,6 +45,7 @@ const ShortAnswer: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, f
className='Textarea' className='Textarea'
onBlur={onBlur} onBlur={onBlur}
maxlength={255} maxlength={255}
value={value}
onInput={(e) => setValue((e.target as HTMLTextAreaElement).value)}/> onInput={(e) => setValue((e.target as HTMLTextAreaElement).value)}/>
<View className='text-muted mt-2'>3</View> <View className='text-muted mt-2'>3</View>
@ -54,7 +55,6 @@ const ShortAnswer: FC<Props> = ({data, onAnswer, onUpAndDown, index, validate, f
</View>} </View>}
{frequency == 0 && <View className='mt-3'> {frequency == 0 && <View className='mt-3'>
<View className='font-weight my-3'></View> <View className='font-weight my-3'></View>
<View>{data.analysis}</View> <View>{data.analysis}</View>

@ -17,3 +17,12 @@
.depForm { .depForm {
padding: 20px 20px env(safe-area-inset-bottom); padding: 20px 20px env(safe-area-inset-bottom);
} }
.depInput {
padding: 10rpx 20px;
margin: 30px;
background: #F5F8F7;
border-radius: 4px;
border-radius: 10rpx;
overflow: hidden;
}

@ -1,81 +1,14 @@
import {FC, useEffect, useState} from "react"; import React, {FC, useEffect, useState} from "react";
import {AddDepProps, ManageApi} from "@/api/manage"; import {AddDepProps, ManageApi} from "@/api/manage";
import {Button, View, Input, Form} from "@tarojs/components"; import {View, Input} from "@tarojs/components";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import {Profile} from '@/store' import {Profile} from '@/store'
import './depAdmin.scss' import './depAdmin.scss'
import PopPut from "@/components/popPut/popPut"; import PopPut from "@/components/popPut/popPut";
import folder from '@/static/img/folder.png' import folder from '@/static/img/folder.png'
import {getCurrentInstance} from "@tarojs/runtime"; import {getCurrentInstance} from "@tarojs/runtime";
import CustomPageContainer from "@/components/custom-page-container/custom-page-container"; import ShowModel from "@/components/showModel/showModel";
interface ChangeDataProps {
putCompany: Manage | null
parent_id: number
getDeps: () => Promise<void>
}
const ChangeData: FC<ChangeDataProps> = ({putCompany, getDeps, parent_id}: ChangeDataProps) => {
const {company} = Profile.useContainer()
const [name, setName] = useState<string>('')
const [disable, setDisable] = useState(false)
const company_id = putCompany?.company_id || company?.id || 0
useEffect(() => {
if (putCompany) {
setName(putCompany.name)
}
}, [])
async function submit() {
if (!name) {
Taro.showToast({title: "请认真填写", icon: "error"})
return
}
setDisable(true)
Taro.showLoading()
try {
const data: AddDepProps = {
id: putCompany?.id || null,
name,
parent_id: putCompany?.parent_id || parent_id || 0,
company_id: company_id,
sort: putCompany?.sort || 0
}
if (putCompany) {
await ManageApi.putDep(data)
} else {
await ManageApi.addDep(data)
}
setTimeout(() => Taro.showToast({title: '操作成功'}))
await getDeps()
} catch (e) {
}
Taro.hideLoading()
setDisable(false)
}
return (
<View className='depForm'>
<View className='mt-2 text-center font-weight font-34'>{putCompany ? '修改' + putCompany.name : '添加部门'}</View>
<Form className='form mt-3'>
<View className='item'>
<View></View>
<Input
focus
confirmHold
holdKeyboard
cursorSpacing={151}
placeholder='请输入部门名称'
value={name}
onInput={(event) => setName(event.detail.value)}/>
</View>
<Button className='mt-3 button' formType='submit' onClick={submit} disabled={disable}></Button>
</Form>
</View>
)
}
const DepAdmin: FC = () => { const DepAdmin: FC = () => {
const params = getCurrentInstance()?.router?.params as { dep_id: string, name: string, id: string } const params = getCurrentInstance()?.router?.params as { dep_id: string, name: string, id: string }
@ -83,6 +16,9 @@ const DepAdmin: FC = () => {
const [show, setShow] = useState(false) const [show, setShow] = useState(false)
const [users, setUsers] = useState<User[]>([]) const [users, setUsers] = useState<User[]>([])
const [putCompany, setPutCompany] = useState<Manage | null>(null) const [putCompany, setPutCompany] = useState<Manage | null>(null)
const [depName, setDepName] = useState('')
const {company} = Profile.useContainer()
async function getData() { async function getData() {
show && setShow(false) show && setShow(false)
@ -94,6 +30,11 @@ const DepAdmin: FC = () => {
} }
function showPop(company: Manage | null) { function showPop(company: Manage | null) {
if (company) {
setDepName(company.name)
} else {
setDepName('')
}
setPutCompany(company) setPutCompany(company)
setShow(true) setShow(true)
} }
@ -129,12 +70,12 @@ const DepAdmin: FC = () => {
case 0: case 0:
Taro.navigateTo({url: `/pages/manage/depCur/depCur?id=${item.id}`}) Taro.navigateTo({url: `/pages/manage/depCur/depCur?id=${item.id}`})
break break
case 2:
showPop(item)
break
case 1: case 1:
Taro.navigateTo({url: `/pages/manage/depAdmin/depAdmin?dep_id=${item.id}&name=${item.name}&id=${item.id}`}) Taro.navigateTo({url: `/pages/manage/depAdmin/depAdmin?dep_id=${item.id}&name=${item.name}&id=${item.id}`})
break break
case 2:
showPop(item)
break
case 3: case 3:
del(item.name, item.id) del(item.name, item.id)
break break
@ -216,8 +157,32 @@ const DepAdmin: FC = () => {
}) })
} }
Taro.useDidShow(getData) async function addDep() {
if (!depName) {
Taro.showToast({title: "请认真填写", icon: "error"})
return
}
try {
const company_id = putCompany?.company_id || company?.id || 0
const data: AddDepProps = {
id: putCompany?.id || null,
name: depName,
parent_id: putCompany ? putCompany?.parent_id : manages.length,
company_id: company_id,
sort: putCompany?.sort || 0
}
if (putCompany) {
await ManageApi.putDep(data)
} else {
await ManageApi.addDep(data)
}
setTimeout(() => Taro.showToast({title: '操作成功'}))
await getData()
} catch (e) {
}
}
Taro.useDidShow(getData)
useEffect(() => { useEffect(() => {
Taro.setNavigationBarTitle({ Taro.setNavigationBarTitle({
@ -226,7 +191,7 @@ const DepAdmin: FC = () => {
}) })
return ( return (
<Profile.Provider> <>
<View> <View>
{manages.map(d => <PopPut {manages.map(d => <PopPut
key={d.id} key={d.id}
@ -236,15 +201,13 @@ const DepAdmin: FC = () => {
leftImage={folder} leftImage={folder}
/>)} />)}
{ {users.map(d => <PopPut
users.map(d => <PopPut
key={d.id} key={d.id}
leftImage={d.avatar} leftImage={d.avatar}
title={d.name} title={d.name}
onClick={() => userManagesSheet(d)} onClick={() => userManagesSheet(d)}
content={['学员', '管理员', '超级管理员'][d.role_type]} content={['学员', '管理员', '超级管理员'][d.role_type]}
/>) />)}
}
<View className='text-center text-muted mt-3'>- -</View> <View className='text-center text-muted mt-3'>- -</View>
@ -256,13 +219,27 @@ const DepAdmin: FC = () => {
</View> </View>
</View> </View>
<CustomPageContainer show={show} round onAfterLeave={() => setShow(false)}> <ShowModel
<View> show={show}
{show && <ChangeData getDeps={getData} putCompany={putCompany} parent_id={Number(params.id)}/>} title={putCompany?.name ? `修改${putCompany.name}` : '添加部门'}
</View> onClickOverlay={() => setShow(false)}
</CustomPageContainer> onOk={addDep}
>
<Input placeholder='添加部门名称'
className='depInput'
value={depName}
onInput={(e) => setDepName(e.detail.value)}/>
</ShowModel>
</>
)
}
const DepAdminIndex: FC = () => {
return (
<Profile.Provider>
<DepAdmin/>
</Profile.Provider> </Profile.Provider>
) )
} }
export default DepAdmin export default DepAdminIndex

@ -4,8 +4,8 @@
padding: 20px; padding: 20px;
} }
.time { //.time {
border-bottom: 1px solid #ddd; // border-bottom: 1px solid #ddd;
padding: 30px 15px; // padding: 30px 15px;
border-radius: 10px; // border-radius: 10px;
} //}

@ -1,11 +1,12 @@
import {FC, useCallback, useEffect, useState} from "react"; import {FC, useCallback, useEffect, useState} from "react";
import {Button, Image, Picker, View} from "@tarojs/components"; import {Image, Picker, View} from "@tarojs/components";
import styles from './offline.module.scss' import styles from './offline.module.scss'
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import {curriculum} from "@/api"; import {curriculum} from "@/api";
import {formatDate} from "@/utils/time"; import {formatDate} from "@/utils/time";
import {getSetting, authorize} from "@tarojs/taro"; import {getSetting, authorize} from "@tarojs/taro";
import PopPut from "@/components/popPut/popPut"; import PopPut from "@/components/popPut/popPut";
import MyButton from "@/components/button/MyButton";
const Offline: FC = () => { const Offline: FC = () => {
const [manages, setManages] = useState<Manage[]>([]) const [manages, setManages] = useState<Manage[]>([])
@ -24,7 +25,6 @@ const Offline: FC = () => {
useEffect(() => { useEffect(() => {
if (!depid) { if (!depid) {
// Taro.showToast({title: '请选择部门', icon: 'error'})
return return
} }
@ -46,13 +46,10 @@ const Offline: FC = () => {
Taro.downloadFile({ Taro.downloadFile({
url: qrcodeUrl, url: qrcodeUrl,
success(res) { success(res) {
console.log({res})
setTempFilePath(res.tempFilePath) setTempFilePath(res.tempFilePath)
}, },
fail(err) { fail() {
console.log({err})
setError("请求失败"); setError("请求失败");
// Taro.showToast({title: '操作失败', icon: 'error'})
}, },
complete() { complete() {
setDownloading(false) setDownloading(false)
@ -83,11 +80,6 @@ const Offline: FC = () => {
} }
}, [tempFilePath]) }, [tempFilePath])
// function handleWriteFile() {
//
// }
const handleSaveCode = useCallback(() => { const handleSaveCode = useCallback(() => {
getSetting({ getSetting({
success: function ({authSetting}) { success: function ({authSetting}) {
@ -111,21 +103,14 @@ const Offline: FC = () => {
return ( return (
<View className={styles.page}> <View className={styles.page}>
<View className={'flex justify-between ' + styles.time}> <Picker mode="date" value={start} onChange={(e) => setStart(e.detail.value + ' 8:00:00')} name='start'>
<Picker mode="date" value={start} onChange={(e) => setStart(e.detail.value)} name='start'> <PopPut title='开始时间' content={start}/>
<View>
{start}
</View>
</Picker> </Picker>
<View></View>
<Picker mode="date" value={start} onChange={(e) => setEnd(e.detail.value)} name='end'> <Picker mode="date" value={end} onChange={(e) => setEnd(e.detail.value + ' 18:00:00')} name='end'>
<View> <PopPut title='结束时间' content={end}/>
{end}
</View>
</Picker> </Picker>
</View>
<View> <View>
<Picker mode='selector' range={manages} onChange={change} rangeKey='name'> <Picker mode='selector' range={manages} onChange={change} rangeKey='name'>
@ -142,7 +127,7 @@ const Offline: FC = () => {
style={{width: '80%'}} style={{width: '80%'}}
/> />
{error && <View>{error}</View>}` {error && <View>{error}</View>}`
<Button className='button' onClick={handleSaveCode}></Button> <MyButton onClick={handleSaveCode}></MyButton>
</View>} </View>}
</View> </View>
) )

@ -52,7 +52,7 @@ body {
justify-content: center; justify-content: center;
} }
Image { .image {
width: 68px; width: 68px;
height: 68px; height: 68px;
background: #ddd; background: #ddd;

Loading…
Cancel
Save