Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
H
huamu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
郭铭瑶
huamu
Commits
0c2e2c5a
Commit
0c2e2c5a
authored
Sep 14, 2021
by
郭铭瑶
🤘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
试打包
parent
06e2b1f1
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
118 additions
and
54 deletions
+118
-54
api.ts
src/ajax/api.ts
+5
-4
useAliOss.ts
src/hooks/useAliOss.ts
+7
-1
useFetch.ts
src/hooks/useFetch.ts
+7
-1
shims-vue.d.ts
src/shims-vue.d.ts
+2
-1
actions.ts
src/store/actions.ts
+4
-1
mutations.ts
src/store/mutations.ts
+3
-0
state.ts
src/store/state.ts
+7
-0
activity-list-modal.vue
src/view/components/activity-list-modal.vue
+17
-12
nav-bar.vue
src/view/components/nav-bar.vue
+6
-5
new-activity-drawer.vue
src/view/components/new-activity-drawer.vue
+50
-17
search-modal.vue
src/view/components/search-modal.vue
+1
-1
struct-modal.vue
src/view/components/struct-modal.vue
+6
-10
main.vue
src/view/main.vue
+1
-0
tsconfig.json
tsconfig.json
+2
-1
No files found.
src/ajax/api.ts
View file @
0c2e2c5a
...
...
@@ -12,10 +12,11 @@ const getCookie = (name: string): string | null => {
switch
(
process
.
env
.
NODE_ENV
)
{
case
'production'
:
BASE_URL
=
'https://survey.maicedata.com/public/api/data/'
TOKEN
=
LZString
.
decompressFromEncodedURIComponent
(
getCookie
(
'__DM_TOKEN__'
)
||
localStorage
.
get
(
'dm_token_'
),
)
BASE_URL
=
'https://survey.maicedata.com/api/data/'
// TOKEN = LZString.decompressFromEncodedURIComponent(
// getCookie('__DM_TOKEN__') || localStorage.get('dm_token_'),
// )
TOKEN
=
'91e315a9-b2a8-4950-97fa-9dbf84a230d6'
break
default
:
BASE_URL
=
'/api'
...
...
src/hooks/useAliOss.ts
View file @
0c2e2c5a
...
...
@@ -2,10 +2,12 @@ import OSS from 'ali-oss'
import
{
useFetchAuth
}
from
'@/hooks/useFetch'
import
md5
from
'md5'
import
{
api
}
from
'@/ajax'
import
store
from
'@/store'
const
auth
=
(
await
useFetchAuth
())?.
token
const
{
auth
}
=
store
.
state
export
default
async
function
useAliOss
(
file
:
any
)
{
console
.
log
(
'auth'
,
auth
)
const
client
=
new
OSS
({
region
:
auth
.
region
,
accessKeyId
:
auth
.
access_key_id
,
...
...
@@ -19,9 +21,13 @@ export default async function useAliOss(file: any) {
return
new
Promise
((
resolve
:
any
)
=>
{
fr
.
readAsArrayBuffer
(
file
)
fr
.
onload
=
async
(
e
)
=>
{
console
.
log
(
'e'
,
e
)
const
buffer
=
new
OSS
.
Buffer
(
e
.
target
&&
e
.
target
.
result
)
console
.
log
(
'buffer'
,
buffer
)
const
key
=
`
${
api
.
BASE_URL
}
/huamu_
${
md5
(
buffer
)}
_
${
filename
}
`
console
.
log
(
'key'
,
key
)
const
res
=
await
client
.
put
(
key
,
buffer
)
console
.
log
(
'res'
,
res
)
resolve
(
res
.
url
)
}
})
...
...
src/hooks/useFetch.ts
View file @
0c2e2c5a
import
{
ajax
,
api
}
from
'@/ajax'
interface
QueryProps
{
a
?:
string
q
?:
string
...
...
@@ -29,6 +28,13 @@ export async function useFetchActivity(params: QueryProps) {
})
return
res
&&
res
.
data
&&
res
.
data
.
result
}
export
async
function
usePostActivity
(
params
:
QueryProps
)
{
const
res
=
await
ajax
.
post
({
url
:
api
.
ACTIVITY
,
params
,
})
return
res
&&
res
.
data
&&
res
.
data
.
result
}
export
async
function
useFetchArea
(
params
:
QueryProps
)
{
const
res
=
await
ajax
.
get
({
url
:
api
.
AREA
,
...
...
src/shims-vue.d.ts
View file @
0c2e2c5a
...
...
@@ -14,6 +14,7 @@ declare module '*.png'
declare
module
'*.jpg'
declare
module
'*.jpeg'
declare
module
'*.gif'
declare
module
'*.svg'
declare
const
LZString
:
{
decompressFromEncodedURIComponent
:
any
...
...
src/store/actions.ts
View file @
0c2e2c5a
import
{
Commit
,
Dispatch
}
from
'./index'
import
{
useFetchOrg
,
useFetchMember
}
from
'@/hooks/useFetch'
import
{
useFetchOrg
,
useFetchMember
,
useFetchAuth
}
from
'@/hooks/useFetch'
import
dayjs
from
'@/util/dayjs'
import
state
from
'./state'
...
...
@@ -9,6 +9,9 @@ interface Method {
}
export
default
{
async
getAuth
({
commit
}:
Method
)
{
commit
(
'SET_AUTH'
,
(
await
useFetchAuth
())?.
token
)
},
async
getBasicInfo
({
commit
}:
Method
,
query
?:
string
)
{
commit
(
'SET_BASIC_INFO'
,
{
sum
:
await
getSum
(
query
),
...
...
src/store/mutations.ts
View file @
0c2e2c5a
...
...
@@ -6,6 +6,9 @@ export default {
SET_LOADING
(
state
:
GlobalStateProps
,
val
:
boolean
)
{
state
.
showLoading
=
val
},
SET_AUTH
(
state
:
GlobalStateProps
,
val
:
any
)
{
state
.
auth
=
val
},
SET_SHOW_BASIC_INFO
(
state
:
GlobalStateProps
,
val
:
boolean
)
{
state
.
showBasicInfo
=
val
},
...
...
src/store/state.ts
View file @
0c2e2c5a
export
default
{
showLoading
:
false
,
auth
:
{
region
:
''
,
access_key_id
:
''
,
access_key_secret
:
''
,
bucket
:
''
,
security_token
:
''
,
},
showBasicInfo
:
true
,
showFilterDrawer
:
false
,
showActivityDrawer
:
false
,
...
...
src/view/components/activity-list-modal.vue
View file @
0c2e2c5a
...
...
@@ -26,9 +26,9 @@
:is-date-disabled=
"disableDateStart"
/>
</n-form-item>
<n-form-item
path=
"dateEn
e
"
>
<n-form-item
path=
"dateEn
d
"
>
<n-date-picker
v-model:value=
"model.dateEn
e
"
v-model:value=
"model.dateEn
d
"
class=
"date-picker"
type=
"date"
clearable
...
...
@@ -104,7 +104,7 @@
</n-space>
</
template
>
</n-modal>
<NewActivityDrawer
:data=
"activityData"
/>
<NewActivityDrawer
:data=
"activityData"
:cb=
"fetchList"
/>
</template>
<
script
lang=
"ts"
setup
>
...
...
@@ -145,14 +145,17 @@ watch(
()
=>
model
.
value
,
(
cur
)
=>
{
const
query
=
[]
cur
.
dateRange
&&
cur
.
dateRange
.
length
>
0
&&
query
.
push
(
`paths @ "活动日期" && integer >=
${
cur
.
dateRange
[
0
]}
`
)
&&
query
.
push
(
`paths @ "活动日期" && integer <=
${
cur
.
dateRange
[
1
]}
`
)
// TODO 出席率区间如何搜索
cur
.
dateStart
&&
query
.
push
(
`paths @ "活动日期" && number >=
${
+
(
cur
.
dateStart
+
''
).
slice
(
0
,
10
)}
`
,
)
cur
.
dateEnd
&&
query
.
push
(
`paths @ "活动日期" && number <=
${
+
(
cur
.
dateEnd
+
''
).
slice
(
0
,
10
)}
`
,
)
cur
.
rateStart
&&
query
.
push
(
`paths @ "出席率" &&
integ
er >=
${
cur
.
rateStart
}
`
)
cur
.
rateEnd
&&
query
.
push
(
`paths @ "出席率" &&
integ
er <=
${
cur
.
rateEnd
}
`
)
query
.
push
(
`paths @ "出席率" &&
numb
er >=
${
cur
.
rateStart
}
`
)
cur
.
rateEnd
&&
query
.
push
(
`paths @ "出席率" &&
numb
er <=
${
cur
.
rateEnd
}
`
)
cur
.
type
&&
query
.
push
(
`paths @ "标签类别" && string == "
${
cur
.
type
}
"`
)
fetchList
(
query
.
length
>
0
?
query
.
join
(
','
)
:
undefined
)
},
...
...
@@ -188,7 +191,9 @@ const columns = [
{},
{
default
:
()
=>
row
[
'活动日期'
]
?
dayjs
(
row
[
'活动日期'
]).
format
(
'll'
)
:
''
,
row
[
'活动日期'
]
?
dayjs
(
+
(
row
[
'活动日期'
]
+
'000'
)).
format
(
'll'
)
:
''
,
},
)
},
...
...
@@ -199,7 +204,7 @@ const columns = [
render
(
row
:
any
)
{
return
row
[
'标签类别'
]
?
h
(
NTag
,
()
=>
NTag
,
{
size
:
'small'
,
type
:
row
[
'标签类别'
]
...
...
src/view/components/nav-bar.vue
View file @
0c2e2c5a
...
...
@@ -115,7 +115,7 @@ import nav3 from '@images/nav3.svg'
import
nav5
from
'@images/nav5.svg'
import
menus
from
'@/util/menus'
const
curMenu
=
ref
(
menus
[
0
])
const
curMenu
=
ref
<
any
>
(
menus
[
0
])
const
showFilterDrawer
=
computed
(()
=>
store
.
state
.
showFilterDrawer
)
const
showBuildingDrawer
=
computed
(()
=>
store
.
state
.
showBuildingDrawer
)
...
...
@@ -158,7 +158,7 @@ const options = [
},
]
const
searchKey
=
ref
<
string
|
null
>
(
null
)
const
searchKey
=
ref
<
string
|
undefined
>
(
undefined
)
const
isLoading
=
ref
(
false
)
const
showResult
=
ref
(
false
)
const
resultData
=
ref
<
any
>
({})
...
...
@@ -210,10 +210,11 @@ const handleSelect = (data: any) => {
showResult
.
value
=
false
}
const
toPage
=
(
id
:
string
)
=>
{
const
toPage
=
(
id
?
:
string
)
=>
{
if
(
!
id
)
return
window
.
parent
.
_global_datamap_emit
&&
window
.
parent
.
_global_datamap_emit
.
emit
(
'CHANGE_PAGE_BY_ID_EVENT'
,
id
)
const
parent
=
window
.
parent
as
any
parent
.
_global_datamap_emit
&&
parent
.
_global_datamap_emit
.
emit
(
'CHANGE_PAGE_BY_ID_EVENT'
,
id
)
}
</
script
>
...
...
src/view/components/new-activity-drawer.vue
View file @
0c2e2c5a
...
...
@@ -11,12 +11,12 @@
<div
class=
"head"
>
<p>
{{
mode
?
basicData
.
name
:
'新增活动'
}}
</p>
<n-space>
<n-button
size=
"small"
@
click=
"closeDrawer
(false)
"
>
取消
</n-button>
<n-button
size=
"small"
@
click=
"closeDrawer"
>
取消
</n-button>
<template
v-if=
"mode === 'view'"
>
<n-button
type=
"error"
size=
"small"
@
click=
"mode = 'modify'"
>
编辑
</n-button>
<n-button
type=
"primary"
size=
"small"
@
click=
"submit"
>
<n-button
type=
"primary"
size=
"small"
>
<template
#
icon
>
<n-icon
size=
".12rem"
>
<svg-icon
:data=
"exportIcon"
original
/>
...
...
@@ -76,7 +76,11 @@
/>
</n-form-item-gi>
<n-form-item-gi
:span=
"12"
label=
"活动日期"
path=
"date"
>
<p
v-if=
"mode === 'view'"
>
{{ dayjs(basicData.date).format('ll') }}
</p>
<n-date-picker
v-else
v-model:value=
"basicData.date"
:disabled=
"mode === 'view'"
style=
"width: 100%"
...
...
@@ -154,8 +158,8 @@
<n-form-item-gi
v-if=
"memberData.fileType === 'file'"
:span=
"24"
>
<n-upload
style=
"width: 100%"
action=
"http://www.mocky.io/v2/5e4bafc63100007100d8b70f"
accept=
".docx,.doc,.xlsx,.xls,.csv,.txt"
:on-before-upload=
"onChange"
>
<n-button>
上传附件
</n-button>
</n-upload>
...
...
@@ -263,21 +267,27 @@
<
script
lang=
"ts"
setup
>
import
store
from
'@/store'
import
{
computed
,
onMounted
,
PropType
,
ref
,
watch
}
from
'vue'
import
{
NForm
}
from
'naive-ui'
import
{
FormRules
,
NForm
,
useMessage
}
from
'naive-ui'
import
exportIcon
from
'@images/export.svg'
import
{
activity
}
from
'@/util/tags'
import
{
useFetchOrg
}
from
'@/hooks/useFetch'
import
{
useFetchOrg
,
usePostActivity
}
from
'@/hooks/useFetch'
import
dayjs
from
'@/util/dayjs'
import
useAliOss
from
'@/hooks/useAliOss'
const
message
=
useMessage
()
const
props
=
defineProps
({
data
:
{
type
:
Object
as
PropType
<
{
[
key
:
string
]:
any
}
>
,
default
:
null
,
},
cb
:
{
type
:
Function
as
PropType
<
(
query
?:
string
)
=>
unknown
>
,
default
:
null
,
},
})
const
mode
=
ref
<
string
|
null
>
(
null
)
const
orgOptions
=
ref
([])
const
orgOptions
=
ref
<
any
[]
>
([])
onMounted
(
async
()
=>
{
orgOptions
.
value
=
(
await
useFetchOrg
({
...
...
@@ -317,9 +327,9 @@ const describeOptions = [
const
basicRef
=
ref
<
typeof
NForm
|
null
>
(
null
)
const
memberRef
=
ref
<
typeof
NForm
|
null
>
(
null
)
const
detailRef
=
ref
<
typeof
NForm
|
null
>
(
null
)
const
basicData
=
ref
({})
const
memberData
=
ref
({})
const
detailData
=
ref
({})
const
basicData
=
ref
<
any
>
({})
const
memberData
=
ref
<
any
>
({})
const
detailData
=
ref
<
any
>
({})
watch
(
()
=>
props
.
data
,
...
...
@@ -334,7 +344,7 @@ watch(
name
:
data
[
'活动名称'
],
type
:
data
[
'标签类别'
],
orgName
:
data
[
'党组织名称'
],
date
:
data
[
'活动日期'
]
&&
dayjs
(
data
[
'活动日期'
]).
format
(
'll'
)
,
date
:
+
(
data
[
'活动日期'
]
+
'000'
)
||
null
,
address
:
data
[
'活动地址'
],
}
const
isFile
=
data
[
'签到表文件'
]
&&
data
[
'签到表文件'
].
length
>
0
...
...
@@ -370,7 +380,7 @@ watch(
{
immediate
:
true
},
)
const
rules
=
{
const
rules
:
FormRules
=
{
name
:
{
required
:
true
,
trigger
:
[
'blur'
,
'input'
],
...
...
@@ -421,16 +431,34 @@ const rules = {
},
}
const
submit
=
()
=>
{
console
.
log
(
basicData
.
value
,
memberData
.
value
,
detailData
.
value
)
const
submit
=
async
()
=>
{
let
noMistake
=
true
basicRef
.
value
?.
validate
((
errors
:
any
)
=>
errors
&&
(
noMistake
=
false
))
memberRef
.
value
?.
validate
((
errors
:
any
)
=>
errors
&&
(
noMistake
=
false
))
detailRef
.
value
?.
validate
((
errors
:
any
)
=>
errors
&&
(
noMistake
=
false
))
if
(
noMistake
)
{
// TODO 请求提交数据
if
(
!
noMistake
)
return
console
.
log
(
basicData
.
value
,
memberData
.
value
,
detailData
.
value
)
if
(
mode
.
value
===
'modify'
)
{
}
else
{
const
{
name
,
type
,
orgName
,
date
,
address
}
=
basicData
.
value
const
{
count
,
excludeCount
}
=
memberData
.
value
const
{
attachment
}
=
detailData
.
value
const
data
=
{
活动名称
:
name
,
标签类别
:
type
,
党组织名称
:
orgName
,
活动日期
:
+
(
date
+
''
).
slice
(
0
,
10
),
// 截掉10位后的10,不然这接口会认为不是时间戳
活动地址
:
address
,
实际参与人数
:
count
,
不计入参与活动党员人数
:
excludeCount
,
活动内容描述
:
attachment
,
}
await
usePostActivity
({
extra
:
data
,
})
closeDrawer
()
props
.
cb
&&
props
.
cb
()
message
.
success
(
'活动新增成功'
)
}
}
...
...
@@ -455,6 +483,11 @@ function handlePreview(file: any) {
previewImageUrl
.
value
=
url
showPhoto
.
value
=
true
}
async
function
onChange
(
options
:
any
)
{
console
.
log
(
'change'
,
options
)
await
useAliOss
(
options
.
file
.
file
)
}
</
script
>
<
style
lang=
"stylus"
scoped
>
...
...
src/view/components/search-modal.vue
View file @
0c2e2c5a
...
...
@@ -132,7 +132,7 @@ import { computed, PropType, ref, watch } from 'vue'
import
{
ArrowForward
}
from
'@vicons/ionicons5'
const
props
=
defineProps
({
data
:
{
type
:
Object
as
PropType
<
{
organization
:
[];
member
:
[]
}
>
,
type
:
Object
as
PropType
<
{
organization
:
any
[];
member
:
any
[]
}
>
,
required
:
true
,
},
visible
:
{
...
...
src/view/components/struct-modal.vue
View file @
0c2e2c5a
...
...
@@ -49,7 +49,7 @@
{{
item
.
label
}}
</p>
-->
<n-menu
:on-update:value=
"
(_, item) => setSub(item)
"
:on-update:value=
"
toSetSub
"
class=
"sub-menu"
:value=
"subKey"
:options=
"subList"
...
...
@@ -338,10 +338,10 @@ const close = () => {
function
renderIcon
()
{
return
()
=>
h
(
PartyIcon
)
}
const
defaultData
=
ref
({})
// 中共上海市浦东新区花木街道工作委员会
const
administration
=
ref
({})
// 行政党组
const
institution
=
ref
({})
// 机关事业单位党总支
const
communityParty
=
ref
({})
// 社区党委
const
defaultData
=
ref
<
any
>
({})
// 中共上海市浦东新区花木街道工作委员会
const
administration
=
ref
<
any
>
({})
// 行政党组
const
institution
=
ref
<
any
>
({})
// 机关事业单位党总支
const
communityParty
=
ref
<
any
>
({})
// 社区党委
const
belongToInstitution
=
ref
<
any
[]
>
([])
const
belongToCommunityParty
=
ref
<
any
[]
>
([])
...
...
@@ -490,7 +490,6 @@ const handleExpand = (val: string[]) => {
}
else
{
expandedKeys
.
value
=
[
val
[
val
.
length
-
1
]]
}
console
.
log
(
'expandedKeys'
,
expandedKeys
.
value
)
if
(
expandedKeys
.
value
.
length
===
1
&&
expandedKeys
.
value
[
0
].
includes
(
'-'
))
{
expandedKeys
.
value
=
[]
subExpandedKeys
.
value
=
[]
...
...
@@ -526,7 +525,6 @@ const setCurKey = (val: string, item: any) => {
watch
(
()
=>
curMenu
.
value
,
async
(
data
)
=>
{
console
.
log
(
'cur-menu: '
,
data
,
menus
.
value
)
if
(
data
&&
data
.
_hasSub
)
{
if
(
data
.
subList
&&
data
.
subList
.
length
>
0
)
{
await
Promise
.
all
(
...
...
@@ -571,12 +569,11 @@ function setSub(data: any) {
curMenu
.
value
=
null
return
}
console
.
log
(
'set-sub: '
,
data
)
subKey
.
value
=
data
&&
data
.
key
curMenu
.
value
=
data
}
const
toSetSub
=
(
_
:
unknown
,
item
:
any
)
=>
setSub
(
item
)
function
onSubExpand
(
keys
:
string
[])
{
console
.
log
(
'sub-expand: '
,
keys
)
if
(
subExpandedKeys
.
value
.
length
===
0
||
keys
.
length
===
0
)
{
subExpandedKeys
.
value
=
keys
}
else
if
(
keys
[
keys
.
length
-
1
].
startsWith
(
subExpandedKeys
.
value
[
0
]))
{
...
...
@@ -584,7 +581,6 @@ function onSubExpand(keys: string[]) {
}
else
{
subExpandedKeys
.
value
=
[
keys
[
keys
.
length
-
1
]]
}
// console.log('222', subExpandedKeys.value)
if
(
subExpandedKeys
.
value
.
length
===
0
)
return
const
cur
=
subList
.
value
.
find
((
e
)
=>
e
.
key
===
subExpandedKeys
.
value
[
0
])
setSub
(
cur
)
...
...
src/view/main.vue
View file @
0c2e2c5a
...
...
@@ -23,6 +23,7 @@ import store from '@/store'
const
showTag
=
ref
(
true
)
const
showReset
=
computed
(()
=>
store
.
state
.
showBasicInfo
)
store
.
dispatch
(
'getAuth'
)
</
script
>
<
style
lang=
"stylus"
>
...
...
tsconfig.json
View file @
0c2e2c5a
...
...
@@ -11,7 +11,8 @@
"baseUrl"
:
"."
,
"lib"
:
[
"esnext"
,
"dom"
],
"paths"
:
{
"@/*"
:
[
"src/*"
]
"@/*"
:
[
"src/*"
],
"@images/*"
:
[
"src/assets/images/*"
]
}
},
"include"
:
[
"src/**/*.ts"
,
"src/**/*.d.ts"
,
"src/**/*.tsx"
,
"src/**/*.vue"
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment