diff --git a/src/components/custom-page-container/custom-page-container.module.scss b/src/components/custom-page-container/custom-page-container.module.scss index d758583..b7a6155 100644 --- a/src/components/custom-page-container/custom-page-container.module.scss +++ b/src/components/custom-page-container/custom-page-container.module.scss @@ -11,7 +11,7 @@ } .overlay { - background: rgba(#000, .5); + background: rgba(#000, .75); position: absolute; top: 0; bottom: 0; diff --git a/src/components/custom-page-container/custom-page-container.tsx b/src/components/custom-page-container/custom-page-container.tsx index 7185887..f82f195 100644 --- a/src/components/custom-page-container/custom-page-container.tsx +++ b/src/components/custom-page-container/custom-page-container.tsx @@ -26,15 +26,17 @@ const PageContainerInner: FC = (props) => { switch (props.position) { case "top": - style.borderRadius = '0 0 30px 30px' + style.borderRadius = '0 0 10px 10px' style.top = 0 break case 'bottom': - style.borderRadius = '30px 30px 0 0' + style.borderRadius = '10px 10px 0 0' style.bottom = 0 break case 'center': - style.borderRadius = '30px' + style.width = '90%' + style.borderRadius = '10px' + style.padding = '0' break } diff --git a/src/components/popPut/popPut.tsx b/src/components/popPut/popPut.tsx index 0dd08bd..56a619d 100644 --- a/src/components/popPut/popPut.tsx +++ b/src/components/popPut/popPut.tsx @@ -47,13 +47,13 @@ const PopPut: FC = ({title, chevron, content, image, isProp, children, sh <> - {opt.leftImage && } + {opt.leftImage && } {title} {content} {!chevron && } - {image && } + {image && } { diff --git a/src/components/showModel/showModel.module.scss b/src/components/showModel/showModel.module.scss new file mode 100644 index 0000000..6ce34f9 --- /dev/null +++ b/src/components/showModel/showModel.module.scss @@ -0,0 +1,7 @@ +.operation { + display: flex; + justify-content: space-around; + padding: 20px 0; + width: 100%; + border-top: 1px solid #eee; +} diff --git a/src/components/showModel/showModel.tsx b/src/components/showModel/showModel.tsx new file mode 100644 index 0000000..ae27cb8 --- /dev/null +++ b/src/components/showModel/showModel.tsx @@ -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 = (pros) => { + return ( + + {pros.title} + {pros.children} + + 取消 + {pros.okText || '确定'} + + + ) +} + +export default ShowModel diff --git a/src/components/topic/shortAnswer.tsx b/src/components/topic/shortAnswer.tsx index bf3fe82..60c3660 100644 --- a/src/components/topic/shortAnswer.tsx +++ b/src/components/topic/shortAnswer.tsx @@ -10,10 +10,10 @@ interface Props { index: number validate: boolean frequency?: number - end?:boolean + end?: boolean } -const ShortAnswer: FC = ({data, onAnswer, onUpAndDown, index, validate, frequency,end}) => { +const ShortAnswer: FC = ({data, onAnswer, onUpAndDown, index, validate, frequency, end}) => { const [value, setValue] = useState('') function onBlur() { @@ -45,6 +45,7 @@ const ShortAnswer: FC = ({data, onAnswer, onUpAndDown, index, validate, f className='Textarea' onBlur={onBlur} maxlength={255} + value={value} onInput={(e) => setValue((e.target as HTMLTextAreaElement).value)}/> 最少3个字 @@ -54,7 +55,6 @@ const ShortAnswer: FC = ({data, onAnswer, onUpAndDown, index, validate, f } - {frequency == 0 && 题目解析 {data.analysis} diff --git a/src/pages/manage/depAdmin/depAdmin.scss b/src/pages/manage/depAdmin/depAdmin.scss index 958bff5..140cd55 100644 --- a/src/pages/manage/depAdmin/depAdmin.scss +++ b/src/pages/manage/depAdmin/depAdmin.scss @@ -17,3 +17,12 @@ .depForm { padding: 20px 20px env(safe-area-inset-bottom); } + +.depInput { + padding: 10rpx 20px; + margin: 30px; + background: #F5F8F7; + border-radius: 4px; + border-radius: 10rpx; + overflow: hidden; +} diff --git a/src/pages/manage/depAdmin/depAdmin.tsx b/src/pages/manage/depAdmin/depAdmin.tsx index 243c1ab..4898665 100644 --- a/src/pages/manage/depAdmin/depAdmin.tsx +++ b/src/pages/manage/depAdmin/depAdmin.tsx @@ -1,81 +1,14 @@ -import {FC, useEffect, useState} from "react"; +import React, {FC, useEffect, useState} from "react"; 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 {Profile} from '@/store' import './depAdmin.scss' import PopPut from "@/components/popPut/popPut"; import folder from '@/static/img/folder.png' 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 -} - -const ChangeData: FC = ({putCompany, getDeps, parent_id}: ChangeDataProps) => { - const {company} = Profile.useContainer() - const [name, setName] = useState('') - 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 ( - - {putCompany ? '修改' + putCompany.name : '添加部门'} -
- - 名称: - setName(event.detail.value)}/> - - - -
-
- ) -} const DepAdmin: FC = () => { 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 [users, setUsers] = useState([]) const [putCompany, setPutCompany] = useState(null) + const [depName, setDepName] = useState('') + const {company} = Profile.useContainer() + async function getData() { show && setShow(false) @@ -94,6 +30,11 @@ const DepAdmin: FC = () => { } function showPop(company: Manage | null) { + if (company) { + setDepName(company.name) + } else { + setDepName('') + } setPutCompany(company) setShow(true) } @@ -129,12 +70,12 @@ const DepAdmin: FC = () => { case 0: Taro.navigateTo({url: `/pages/manage/depCur/depCur?id=${item.id}`}) break - case 2: - showPop(item) - break case 1: Taro.navigateTo({url: `/pages/manage/depAdmin/depAdmin?dep_id=${item.id}&name=${item.name}&id=${item.id}`}) break + case 2: + showPop(item) + break case 3: del(item.name, item.id) 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(() => { Taro.setNavigationBarTitle({ @@ -226,7 +191,7 @@ const DepAdmin: FC = () => { }) return ( - + <> {manages.map(d => { leftImage={folder} />)} - { - users.map(d => userManagesSheet(d)} - content={['学员', '管理员', '超级管理员'][d.role_type]} - />) - } + {users.map(d => userManagesSheet(d)} + content={['学员', '管理员', '超级管理员'][d.role_type]} + />)} - 暂无更多 - @@ -256,13 +219,27 @@ const DepAdmin: FC = () => {
- setShow(false)}> - - {show && } - - + setShow(false)} + onOk={addDep} + > + setDepName(e.detail.value)}/> + + + ) +} + +const DepAdminIndex: FC = () => { + return ( + + ) } -export default DepAdmin +export default DepAdminIndex diff --git a/src/pages/manage/offline/offline.module.scss b/src/pages/manage/offline/offline.module.scss index 5d68914..bb8d2c1 100644 --- a/src/pages/manage/offline/offline.module.scss +++ b/src/pages/manage/offline/offline.module.scss @@ -4,8 +4,8 @@ padding: 20px; } -.time { - border-bottom: 1px solid #ddd; - padding: 30px 15px; - border-radius: 10px; -} +//.time { +// border-bottom: 1px solid #ddd; +// padding: 30px 15px; +// border-radius: 10px; +//} diff --git a/src/pages/manage/offline/offline.tsx b/src/pages/manage/offline/offline.tsx index 7f7639a..dbb4bb9 100644 --- a/src/pages/manage/offline/offline.tsx +++ b/src/pages/manage/offline/offline.tsx @@ -1,11 +1,12 @@ 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 Taro from "@tarojs/taro"; import {curriculum} from "@/api"; import {formatDate} from "@/utils/time"; import {getSetting, authorize} from "@tarojs/taro"; import PopPut from "@/components/popPut/popPut"; +import MyButton from "@/components/button/MyButton"; const Offline: FC = () => { const [manages, setManages] = useState([]) @@ -24,7 +25,6 @@ const Offline: FC = () => { useEffect(() => { if (!depid) { - // Taro.showToast({title: '请选择部门', icon: 'error'}) return } @@ -46,13 +46,10 @@ const Offline: FC = () => { Taro.downloadFile({ url: qrcodeUrl, success(res) { - console.log({res}) setTempFilePath(res.tempFilePath) }, - fail(err) { - console.log({err}) + fail() { setError("请求失败"); - // Taro.showToast({title: '操作失败', icon: 'error'}) }, complete() { setDownloading(false) @@ -83,11 +80,6 @@ const Offline: FC = () => { } }, [tempFilePath]) - - // function handleWriteFile() { - // - // } - const handleSaveCode = useCallback(() => { getSetting({ success: function ({authSetting}) { @@ -111,21 +103,14 @@ const Offline: FC = () => { return ( - - setStart(e.detail.value)} name='start'> - - {start} - - + setStart(e.detail.value + ' 8:00:00')} name='start'> + + - - setEnd(e.detail.value)} name='end'> - - {end} - - - + setEnd(e.detail.value + ' 18:00:00')} name='end'> + + @@ -142,7 +127,7 @@ const Offline: FC = () => { style={{width: '80%'}} /> {error && {error}}` - + 下载 } ) diff --git a/src/static/css/module.scss b/src/static/css/module.scss index 242f09c..92770a2 100644 --- a/src/static/css/module.scss +++ b/src/static/css/module.scss @@ -52,7 +52,7 @@ body { justify-content: center; } - Image { + .image { width: 68px; height: 68px; background: #ddd;