Skip to content

Commit

Permalink
Merge pull request #54 from HXTIA/dev
Browse files Browse the repository at this point in the history
feat: 兼容通知列表
  • Loading branch information
HardenSG authored Jun 10, 2024
2 parents 8096a8b + 6d2fd58 commit 50a51a4
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 39 deletions.
5 changes: 3 additions & 2 deletions scripts/gitHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ const { logUtils, REGISTRY_URL } = require('./constant')
const git = CLI_COMMON_CONFIG().git
const gitHelper = async () => {
const currentBranch = multiProcessCommandExec('git branch --show-current')
const isOffline = currentBranch === 'dev'
logUtils.warn(`⌛️:当前分支:${currentBranch},git release 发版运行中....\n`)

if (currentBranch === 'dev') return
// if (currentBranch === 'dev') return

const isNeedTag = true
const pkg = fileUtils()
Expand All @@ -23,7 +24,7 @@ const gitHelper = async () => {
await exec.promise(`git commit -m "chore(release): ${pkg.version} feature release"`)
await exec.promise('git pull')
await exec.promise(`git push --set-upstream origin ${currentBranch} -f`)
if (isNeedTag) {
if (isNeedTag && !isOffline) {
logUtils.warn('⌛️:需要tag,推送远程标签中.....')
await exec.promise(`git tag v${pkg.version}`)
await exec.promise('git push origin --tags -f')
Expand Down
7 changes: 7 additions & 0 deletions src/pages/main/Index/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export const taskInterUrl = requestUrlCreator({
rootPath: 'WX_WORK',
})

/** 通知列表基础路径 */
export const notifyInterUrl = requestUrlCreator({
rootPath: 'WX_WORK',
absolutePath: '/notifications'
})

/** 任务状态枚举 */
export const TASK_STATUS = {
/** 有效期内 */
Expand All @@ -35,6 +41,7 @@ export const enum FilterType {
READ_UNRESOLVE = 1,
READ_RESOLVE = 2,
ALL_DATA = 100,
NOTIFY_DATA = 101
}

/** 行为映射状态枚举 */
Expand Down
36 changes: 31 additions & 5 deletions src/pages/main/Index/components/Tasklist/task-filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const Index = ({
0: '未完成',
1: '已读',
2: '已完成',
101: '通知列表',
}
return map[val]
}
Expand All @@ -45,12 +46,37 @@ const Index = ({
style={{ background: 'transparent' }}
>
<View style={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
请选择你想查看的筛选类型
请选择你想查看的列表内容
</View>
<View>
<View
style={{
fontSize: '22rpx',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
作业列表
</View>
<DropdownMenu.Option value={100}>全部</DropdownMenu.Option>
<DropdownMenu.Option value={0}>未完成</DropdownMenu.Option>
<DropdownMenu.Option value={1}>已读</DropdownMenu.Option>
<DropdownMenu.Option value={2}>已完成</DropdownMenu.Option>
</View>
<View>
<View
style={{
fontSize: '22rpx',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
通知列表
</View>
<DropdownMenu.Option value={101}>查看全部通知</DropdownMenu.Option>
</View>
<DropdownMenu.Option value={100}>全部</DropdownMenu.Option>
<DropdownMenu.Option value={0}>未完成</DropdownMenu.Option>
<DropdownMenu.Option value={1}>已读</DropdownMenu.Option>
<DropdownMenu.Option value={2}>已完成</DropdownMenu.Option>
</DropdownMenu.Item>
</DropdownMenu>
</View>
Expand Down
69 changes: 43 additions & 26 deletions src/pages/main/Index/components/Tasklist/task-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class Index extends React.PureComponent<TTaskItemProps, TTaskItemState> {
/** 跳转到详情页面 */
// @subscribeHOF(tplIds)
goToDetail() {
if (this.props.taskInfo.notificationUuid) return
console.log(' === 点击卡片,详情页开始跳转 === ')
goTo({
url: URL.Detail,
Expand Down Expand Up @@ -179,7 +180,9 @@ class Index extends React.PureComponent<TTaskItemProps, TTaskItemState> {
}

render() {
const { deadline, title, description } = this.props.taskInfo
const { deadline, updated_at, title, description, content, notificationUuid } =
this.props.taskInfo
const isNotify = !!notificationUuid
const { openDire } = this.state
return (
<SwipeCell
Expand All @@ -193,37 +196,51 @@ class Index extends React.PureComponent<TTaskItemProps, TTaskItemState> {
<View className='left' onClick={this.goToDetail}>
<Text className='left_title'>{title}</Text>
<Text className='left_time'>
截止日期:{timeFormat(deadline, 'YYYY年MM月DD日 hh:mm:ss')}
{deadline ? '截止日期' : '创建时间'}
{timeFormat(deadline || updated_at, 'YYYY年MM月DD日 hh:mm:ss')}
</Text>
<Text className='left_desc'>简介:{formatDesc(description)}</Text>
<Text className='left_desc'>简介:{formatDesc(description || content)}</Text>
</View>
<View className='right'>
<View className='right_tools'>
{/* TODO: 箭头处理 */}
<ArrowDownIcon onClick={this.open} />
{!isNotify ? (
<View className='right'>
<View className='right_tools'>
{/* TODO: 箭头处理 */}
<ArrowDownIcon onClick={this.open} />
</View>
<View className='right_status' style={this.state.statusStyle}>
{/* 状态文字提示 */}
{this.state.statusText}
</View>
</View>
<View className='right_status' style={this.state.statusStyle}>
{/* 状态文字提示 */}
{this.state.statusText}
) : (
<View className='right'>
<View className='right_status' style={this.state.statusStyle}>
{/* 状态文字提示 */}
通知
</View>
</View>
</View>
)}
</View>
<SwipeCell.Actions side='right'>
<View className='opera_area'>
<View className='opera_area_del' onClick={this.deleteTask}>
<DeleteIcon size={40} />
删除
</View>
<View className='opera_area_dynamicStatus' onClick={this.resolveOrReopen}>
{this.state.action === 'RESOLVE' ? (
<ExchangeIcon size={40} />
) : (
<ReplayIcon size={40} />
)}
{this.state.btnFnText}
{!isNotify ? (
<SwipeCell.Actions side='right'>
<View className='opera_area'>
<View className='opera_area_del' onClick={this.deleteTask}>
<DeleteIcon size={40} />
删除
</View>
<View className='opera_area_dynamicStatus' onClick={this.resolveOrReopen}>
{this.state.action === 'RESOLVE' ? (
<ExchangeIcon size={40} />
) : (
<ReplayIcon size={40} />
)}
{this.state.btnFnText}
</View>
</View>
</View>
</SwipeCell.Actions>
</SwipeCell.Actions>
) : (
<></>
)}
</SwipeCell>
)
}
Expand Down
48 changes: 43 additions & 5 deletions src/pages/main/Index/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { View, Text } from '@tarojs/components'
import React, { useCallback, useEffect, useState } from 'react'
import React, { useCallback, useEffect, useMemo, useState } from 'react'
import useRequest from 'src/hooks/useRequest'
import { useSelector } from 'react-redux'
import { RootState } from 'src/store'
import { Authorize } from 'src/components/baseBuiltComp/HocWrap'
import Loading from 'src/components/baseBuiltComp/Loading'
import useUpdateEffect from 'src/hooks/useUpdateEffect'
import TaskList from './components/Tasklist/task-list'
import TaskFilter from './components/Tasklist/task-filter'
import TaskSearch from './components/Tasklist/task-search'
import { TFilterType, TTaskList } from './types'
import { IndexContextProvider, getListInterUrl } from './common'
import { FilterType, IndexContextProvider, getListInterUrl, notifyInterUrl } from './common'

import './index.module.scss'

const Index = () => {
const userStore = useSelector((root: RootState) => root.userinfoModel)
/** 透传:列表项 */
const [lists, setList] = useState<TTaskList>()
/** 透传:筛选规则 */
Expand All @@ -21,7 +25,7 @@ const Index = () => {
/** 透传:搜索的文字 */
const [searchText, setSearchText] = useState('')
/** 透传:请求能力 */
const { loading, run } = useRequest<TTaskList>(
const { loading: workLoading, run: workRun } = useRequest<TTaskList>(
() => {
const baseReqData = {
keyword: searchText,
Expand All @@ -38,6 +42,35 @@ const Index = () => {
{ auto: false, deps: [filterType, page, searchText] },
)

const { loading: notifyLoading, run: notifyRun } = useRequest<TTaskList>(
() => {
return {
type: 'Post',
url: notifyInterUrl,
silent: true,
reqData: {
page,
size: 10,
wechatId: userStore.wechatId,
},
}
},
{ auto: false, deps: [page, userStore] },
)

const run = useCallback(
(...args) => {
if (filterType === FilterType.NOTIFY_DATA) {
return notifyRun(...args)
} else {
return workRun(...args)
}
},
[filterType, notifyRun, workRun],
)

const loading = useMemo(() => notifyLoading || workLoading, [workLoading, notifyLoading])

/** mounted请求初始化数据 */
useEffect(() => {
run().then((res) => {
Expand All @@ -51,8 +84,13 @@ const Index = () => {
}, [])

useUpdateEffect(() => {
console.log(' === 筛选类型变化,即将请求 === ')
run({ page: 1, keyword: '' }).then((res) => {
let reqData = {
page: 1,
}
if (filterType !== FilterType.NOTIFY_DATA) {
reqData['keyword'] = ''
}
run(reqData).then((res) => {
setList(res)
setPage(1)
})
Expand Down
2 changes: 1 addition & 1 deletion src/pages/main/Index/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export type TTaskList = IWork[]
* - 2 read_resolve
* - 100 all_data
*/
export type TFilterType = 0 | 1 | 2 | 100
export type TFilterType = 0 | 1 | 2 | 100 | 101

/** 祖先组件provider透传类型定义 */
export type TPropsThrough = {
Expand Down

0 comments on commit 50a51a4

Please sign in to comment.