Commit 0c2e2c5a authored by 郭铭瑶's avatar 郭铭瑶 🤘

试打包

parent 06e2b1f1
...@@ -12,10 +12,11 @@ const getCookie = (name: string): string | null => { ...@@ -12,10 +12,11 @@ const getCookie = (name: string): string | null => {
switch (process.env.NODE_ENV) { switch (process.env.NODE_ENV) {
case 'production': case 'production':
BASE_URL = 'https://survey.maicedata.com/public/api/data/' BASE_URL = 'https://survey.maicedata.com/api/data/'
TOKEN = LZString.decompressFromEncodedURIComponent( // TOKEN = LZString.decompressFromEncodedURIComponent(
getCookie('__DM_TOKEN__') || localStorage.get('dm_token_'), // getCookie('__DM_TOKEN__') || localStorage.get('dm_token_'),
) // )
TOKEN = '91e315a9-b2a8-4950-97fa-9dbf84a230d6'
break break
default: default:
BASE_URL = '/api' BASE_URL = '/api'
......
...@@ -2,10 +2,12 @@ import OSS from 'ali-oss' ...@@ -2,10 +2,12 @@ import OSS from 'ali-oss'
import { useFetchAuth } from '@/hooks/useFetch' import { useFetchAuth } from '@/hooks/useFetch'
import md5 from 'md5' import md5 from 'md5'
import { api } from '@/ajax' import { api } from '@/ajax'
import store from '@/store'
const auth = (await useFetchAuth())?.token const { auth } = store.state
export default async function useAliOss(file: any) { export default async function useAliOss(file: any) {
console.log('auth', auth)
const client = new OSS({ const client = new OSS({
region: auth.region, region: auth.region,
accessKeyId: auth.access_key_id, accessKeyId: auth.access_key_id,
...@@ -19,9 +21,13 @@ export default async function useAliOss(file: any) { ...@@ -19,9 +21,13 @@ export default async function useAliOss(file: any) {
return new Promise((resolve: any) => { return new Promise((resolve: any) => {
fr.readAsArrayBuffer(file) fr.readAsArrayBuffer(file)
fr.onload = async (e) => { fr.onload = async (e) => {
console.log('e', e)
const buffer = new OSS.Buffer(e.target && e.target.result) const buffer = new OSS.Buffer(e.target && e.target.result)
console.log('buffer', buffer)
const key = `${api.BASE_URL}/huamu_${md5(buffer)}_${filename}` const key = `${api.BASE_URL}/huamu_${md5(buffer)}_${filename}`
console.log('key', key)
const res = await client.put(key, buffer) const res = await client.put(key, buffer)
console.log('res', res)
resolve(res.url) resolve(res.url)
} }
}) })
......
import { ajax, api } from '@/ajax' import { ajax, api } from '@/ajax'
interface QueryProps { interface QueryProps {
a?: string a?: string
q?: string q?: string
...@@ -29,6 +28,13 @@ export async function useFetchActivity(params: QueryProps) { ...@@ -29,6 +28,13 @@ export async function useFetchActivity(params: QueryProps) {
}) })
return res && res.data && res.data.result 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) { export async function useFetchArea(params: QueryProps) {
const res = await ajax.get({ const res = await ajax.get({
url: api.AREA, url: api.AREA,
......
...@@ -14,6 +14,7 @@ declare module '*.png' ...@@ -14,6 +14,7 @@ declare module '*.png'
declare module '*.jpg' declare module '*.jpg'
declare module '*.jpeg' declare module '*.jpeg'
declare module '*.gif' declare module '*.gif'
declare module '*.svg'
declare const LZString: { declare const LZString: {
decompressFromEncodedURIComponent: any decompressFromEncodedURIComponent: any
......
import { Commit, Dispatch } from './index' import { Commit, Dispatch } from './index'
import { useFetchOrg, useFetchMember } from '@/hooks/useFetch' import { useFetchOrg, useFetchMember, useFetchAuth } from '@/hooks/useFetch'
import dayjs from '@/util/dayjs' import dayjs from '@/util/dayjs'
import state from './state' import state from './state'
...@@ -9,6 +9,9 @@ interface Method { ...@@ -9,6 +9,9 @@ interface Method {
} }
export default { export default {
async getAuth({ commit }: Method) {
commit('SET_AUTH', (await useFetchAuth())?.token)
},
async getBasicInfo({ commit }: Method, query?: string) { async getBasicInfo({ commit }: Method, query?: string) {
commit('SET_BASIC_INFO', { commit('SET_BASIC_INFO', {
sum: await getSum(query), sum: await getSum(query),
......
...@@ -6,6 +6,9 @@ export default { ...@@ -6,6 +6,9 @@ export default {
SET_LOADING(state: GlobalStateProps, val: boolean) { SET_LOADING(state: GlobalStateProps, val: boolean) {
state.showLoading = val state.showLoading = val
}, },
SET_AUTH(state: GlobalStateProps, val: any) {
state.auth = val
},
SET_SHOW_BASIC_INFO(state: GlobalStateProps, val: boolean) { SET_SHOW_BASIC_INFO(state: GlobalStateProps, val: boolean) {
state.showBasicInfo = val state.showBasicInfo = val
}, },
......
export default { export default {
showLoading: false, showLoading: false,
auth: {
region: '',
access_key_id: '',
access_key_secret: '',
bucket: '',
security_token: '',
},
showBasicInfo: true, showBasicInfo: true,
showFilterDrawer: false, showFilterDrawer: false,
showActivityDrawer: false, showActivityDrawer: false,
......
...@@ -26,9 +26,9 @@ ...@@ -26,9 +26,9 @@
:is-date-disabled="disableDateStart" :is-date-disabled="disableDateStart"
/> />
</n-form-item> </n-form-item>
<n-form-item path="dateEne"> <n-form-item path="dateEnd">
<n-date-picker <n-date-picker
v-model:value="model.dateEne" v-model:value="model.dateEnd"
class="date-picker" class="date-picker"
type="date" type="date"
clearable clearable
...@@ -104,7 +104,7 @@ ...@@ -104,7 +104,7 @@
</n-space> </n-space>
</template> </template>
</n-modal> </n-modal>
<NewActivityDrawer :data="activityData" /> <NewActivityDrawer :data="activityData" :cb="fetchList" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
...@@ -145,14 +145,17 @@ watch( ...@@ -145,14 +145,17 @@ watch(
() => model.value, () => model.value,
(cur) => { (cur) => {
const query = [] const query = []
cur.dateRange && cur.dateStart &&
cur.dateRange.length > 0 && query.push(
query.push(`paths @ "活动日期" && integer >= ${cur.dateRange[0]}`) && `paths @ "活动日期" && number >= ${+(cur.dateStart + '').slice(0, 10)}`,
query.push(`paths @ "活动日期" && integer <= ${cur.dateRange[1]}`) )
// TODO 出席率区间如何搜索 cur.dateEnd &&
query.push(
`paths @ "活动日期" && number <= ${+(cur.dateEnd + '').slice(0, 10)}`,
)
cur.rateStart && cur.rateStart &&
query.push(`paths @ "出席率" && integer >= ${cur.rateStart}`) query.push(`paths @ "出席率" && number >= ${cur.rateStart}`)
cur.rateEnd && query.push(`paths @ "出席率" && integer <= ${cur.rateEnd}`) cur.rateEnd && query.push(`paths @ "出席率" && number <= ${cur.rateEnd}`)
cur.type && query.push(`paths @ "标签类别" && string == "${cur.type}"`) cur.type && query.push(`paths @ "标签类别" && string == "${cur.type}"`)
fetchList(query.length > 0 ? query.join(',') : undefined) fetchList(query.length > 0 ? query.join(',') : undefined)
}, },
...@@ -188,7 +191,9 @@ const columns = [ ...@@ -188,7 +191,9 @@ const columns = [
{}, {},
{ {
default: () => default: () =>
row['活动日期'] ? dayjs(row['活动日期']).format('ll') : '', row['活动日期']
? dayjs(+(row['活动日期'] + '000')).format('ll')
: '',
}, },
) )
}, },
...@@ -199,7 +204,7 @@ const columns = [ ...@@ -199,7 +204,7 @@ const columns = [
render(row: any) { render(row: any) {
return row['标签类别'] return row['标签类别']
? h( ? h(
NTag, () => NTag,
{ {
size: 'small', size: 'small',
type: row['标签类别'] type: row['标签类别']
......
...@@ -115,7 +115,7 @@ import nav3 from '@images/nav3.svg' ...@@ -115,7 +115,7 @@ import nav3 from '@images/nav3.svg'
import nav5 from '@images/nav5.svg' import nav5 from '@images/nav5.svg'
import menus from '@/util/menus' import menus from '@/util/menus'
const curMenu = ref(menus[0]) const curMenu = ref<any>(menus[0])
const showFilterDrawer = computed(() => store.state.showFilterDrawer) const showFilterDrawer = computed(() => store.state.showFilterDrawer)
const showBuildingDrawer = computed(() => store.state.showBuildingDrawer) const showBuildingDrawer = computed(() => store.state.showBuildingDrawer)
...@@ -158,7 +158,7 @@ const options = [ ...@@ -158,7 +158,7 @@ const options = [
}, },
] ]
const searchKey = ref<string | null>(null) const searchKey = ref<string | undefined>(undefined)
const isLoading = ref(false) const isLoading = ref(false)
const showResult = ref(false) const showResult = ref(false)
const resultData = ref<any>({}) const resultData = ref<any>({})
...@@ -210,10 +210,11 @@ const handleSelect = (data: any) => { ...@@ -210,10 +210,11 @@ const handleSelect = (data: any) => {
showResult.value = false showResult.value = false
} }
const toPage = (id: string) => { const toPage = (id?: string) => {
if (!id) return if (!id) return
window.parent._global_datamap_emit && const parent = window.parent as any
window.parent._global_datamap_emit.emit('CHANGE_PAGE_BY_ID_EVENT', id) parent._global_datamap_emit &&
parent._global_datamap_emit.emit('CHANGE_PAGE_BY_ID_EVENT', id)
} }
</script> </script>
......
...@@ -11,12 +11,12 @@ ...@@ -11,12 +11,12 @@
<div class="head"> <div class="head">
<p>{{ mode ? basicData.name : '新增活动' }}</p> <p>{{ mode ? basicData.name : '新增活动' }}</p>
<n-space> <n-space>
<n-button size="small" @click="closeDrawer(false)">取消</n-button> <n-button size="small" @click="closeDrawer">取消</n-button>
<template v-if="mode === 'view'"> <template v-if="mode === 'view'">
<n-button type="error" size="small" @click="mode = 'modify'"> <n-button type="error" size="small" @click="mode = 'modify'">
编辑 编辑
</n-button> </n-button>
<n-button type="primary" size="small" @click="submit"> <n-button type="primary" size="small">
<template #icon> <template #icon>
<n-icon size=".12rem"> <n-icon size=".12rem">
<svg-icon :data="exportIcon" original /> <svg-icon :data="exportIcon" original />
...@@ -76,7 +76,11 @@ ...@@ -76,7 +76,11 @@
/> />
</n-form-item-gi> </n-form-item-gi>
<n-form-item-gi :span="12" label="活动日期" path="date"> <n-form-item-gi :span="12" label="活动日期" path="date">
<p v-if="mode === 'view'">
{{ dayjs(basicData.date).format('ll') }}
</p>
<n-date-picker <n-date-picker
v-else
v-model:value="basicData.date" v-model:value="basicData.date"
:disabled="mode === 'view'" :disabled="mode === 'view'"
style="width: 100%" style="width: 100%"
...@@ -154,8 +158,8 @@ ...@@ -154,8 +158,8 @@
<n-form-item-gi v-if="memberData.fileType === 'file'" :span="24"> <n-form-item-gi v-if="memberData.fileType === 'file'" :span="24">
<n-upload <n-upload
style="width: 100%" style="width: 100%"
action="http://www.mocky.io/v2/5e4bafc63100007100d8b70f"
accept=".docx,.doc,.xlsx,.xls,.csv,.txt" accept=".docx,.doc,.xlsx,.xls,.csv,.txt"
:on-before-upload="onChange"
> >
<n-button> 上传附件 </n-button> <n-button> 上传附件 </n-button>
</n-upload> </n-upload>
...@@ -263,21 +267,27 @@ ...@@ -263,21 +267,27 @@
<script lang="ts" setup> <script lang="ts" setup>
import store from '@/store' import store from '@/store'
import { computed, onMounted, PropType, ref, watch } from 'vue' 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 exportIcon from '@images/export.svg'
import { activity } from '@/util/tags' import { activity } from '@/util/tags'
import { useFetchOrg } from '@/hooks/useFetch' import { useFetchOrg, usePostActivity } from '@/hooks/useFetch'
import dayjs from '@/util/dayjs' import dayjs from '@/util/dayjs'
import useAliOss from '@/hooks/useAliOss'
const message = useMessage()
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object as PropType<{ [key: string]: any }>, type: Object as PropType<{ [key: string]: any }>,
default: null, default: null,
}, },
cb: {
type: Function as PropType<(query?: string) => unknown>,
default: null,
},
}) })
const mode = ref<string | null>(null) const mode = ref<string | null>(null)
const orgOptions = ref([]) const orgOptions = ref<any[]>([])
onMounted(async () => { onMounted(async () => {
orgOptions.value = ( orgOptions.value = (
await useFetchOrg({ await useFetchOrg({
...@@ -317,9 +327,9 @@ const describeOptions = [ ...@@ -317,9 +327,9 @@ const describeOptions = [
const basicRef = ref<typeof NForm | null>(null) const basicRef = ref<typeof NForm | null>(null)
const memberRef = ref<typeof NForm | null>(null) const memberRef = ref<typeof NForm | null>(null)
const detailRef = ref<typeof NForm | null>(null) const detailRef = ref<typeof NForm | null>(null)
const basicData = ref({}) const basicData = ref<any>({})
const memberData = ref({}) const memberData = ref<any>({})
const detailData = ref({}) const detailData = ref<any>({})
watch( watch(
() => props.data, () => props.data,
...@@ -334,7 +344,7 @@ watch( ...@@ -334,7 +344,7 @@ watch(
name: data['活动名称'], name: data['活动名称'],
type: data['标签类别'], type: data['标签类别'],
orgName: data['党组织名称'], orgName: data['党组织名称'],
date: data['活动日期'] && dayjs(data['活动日期']).format('ll'), date: +(data['活动日期'] + '000') || null,
address: data['活动地址'], address: data['活动地址'],
} }
const isFile = data['签到表文件'] && data['签到表文件'].length > 0 const isFile = data['签到表文件'] && data['签到表文件'].length > 0
...@@ -370,7 +380,7 @@ watch( ...@@ -370,7 +380,7 @@ watch(
{ immediate: true }, { immediate: true },
) )
const rules = { const rules: FormRules = {
name: { name: {
required: true, required: true,
trigger: ['blur', 'input'], trigger: ['blur', 'input'],
...@@ -421,16 +431,34 @@ const rules = { ...@@ -421,16 +431,34 @@ const rules = {
}, },
} }
const submit = () => { const submit = async () => {
console.log(basicData.value, memberData.value, detailData.value)
let noMistake = true let noMistake = true
basicRef.value?.validate((errors: any) => errors && (noMistake = false)) basicRef.value?.validate((errors: any) => errors && (noMistake = false))
memberRef.value?.validate((errors: any) => errors && (noMistake = false)) memberRef.value?.validate((errors: any) => errors && (noMistake = false))
detailRef.value?.validate((errors: any) => errors && (noMistake = false)) detailRef.value?.validate((errors: any) => errors && (noMistake = false))
if (!noMistake) return
if (noMistake) {
// TODO 请求提交数据
console.log(basicData.value, memberData.value, detailData.value) 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) { ...@@ -455,6 +483,11 @@ function handlePreview(file: any) {
previewImageUrl.value = url previewImageUrl.value = url
showPhoto.value = true showPhoto.value = true
} }
async function onChange(options: any) {
console.log('change', options)
await useAliOss(options.file.file)
}
</script> </script>
<style lang="stylus" scoped> <style lang="stylus" scoped>
......
...@@ -132,7 +132,7 @@ import { computed, PropType, ref, watch } from 'vue' ...@@ -132,7 +132,7 @@ import { computed, PropType, ref, watch } from 'vue'
import { ArrowForward } from '@vicons/ionicons5' import { ArrowForward } from '@vicons/ionicons5'
const props = defineProps({ const props = defineProps({
data: { data: {
type: Object as PropType<{ organization: []; member: [] }>, type: Object as PropType<{ organization: any[]; member: any[] }>,
required: true, required: true,
}, },
visible: { visible: {
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
{{ item.label }} {{ item.label }}
</p> --> </p> -->
<n-menu <n-menu
:on-update:value="(_, item) => setSub(item)" :on-update:value="toSetSub"
class="sub-menu" class="sub-menu"
:value="subKey" :value="subKey"
:options="subList" :options="subList"
...@@ -338,10 +338,10 @@ const close = () => { ...@@ -338,10 +338,10 @@ const close = () => {
function renderIcon() { function renderIcon() {
return () => h(PartyIcon) return () => h(PartyIcon)
} }
const defaultData = ref({}) // 中共上海市浦东新区花木街道工作委员会 const defaultData = ref<any>({}) // 中共上海市浦东新区花木街道工作委员会
const administration = ref({}) // 行政党组 const administration = ref<any>({}) // 行政党组
const institution = ref({}) // 机关事业单位党总支 const institution = ref<any>({}) // 机关事业单位党总支
const communityParty = ref({}) // 社区党委 const communityParty = ref<any>({}) // 社区党委
const belongToInstitution = ref<any[]>([]) const belongToInstitution = ref<any[]>([])
const belongToCommunityParty = ref<any[]>([]) const belongToCommunityParty = ref<any[]>([])
...@@ -490,7 +490,6 @@ const handleExpand = (val: string[]) => { ...@@ -490,7 +490,6 @@ const handleExpand = (val: string[]) => {
} else { } else {
expandedKeys.value = [val[val.length - 1]] expandedKeys.value = [val[val.length - 1]]
} }
console.log('expandedKeys', expandedKeys.value)
if (expandedKeys.value.length === 1 && expandedKeys.value[0].includes('-')) { if (expandedKeys.value.length === 1 && expandedKeys.value[0].includes('-')) {
expandedKeys.value = [] expandedKeys.value = []
subExpandedKeys.value = [] subExpandedKeys.value = []
...@@ -526,7 +525,6 @@ const setCurKey = (val: string, item: any) => { ...@@ -526,7 +525,6 @@ const setCurKey = (val: string, item: any) => {
watch( watch(
() => curMenu.value, () => curMenu.value,
async (data) => { async (data) => {
console.log('cur-menu: ', data, menus.value)
if (data && data._hasSub) { if (data && data._hasSub) {
if (data.subList && data.subList.length > 0) { if (data.subList && data.subList.length > 0) {
await Promise.all( await Promise.all(
...@@ -571,12 +569,11 @@ function setSub(data: any) { ...@@ -571,12 +569,11 @@ function setSub(data: any) {
curMenu.value = null curMenu.value = null
return return
} }
console.log('set-sub: ', data)
subKey.value = data && data.key subKey.value = data && data.key
curMenu.value = data curMenu.value = data
} }
const toSetSub = (_: unknown, item: any) => setSub(item)
function onSubExpand(keys: string[]) { function onSubExpand(keys: string[]) {
console.log('sub-expand: ', keys)
if (subExpandedKeys.value.length === 0 || keys.length === 0) { if (subExpandedKeys.value.length === 0 || keys.length === 0) {
subExpandedKeys.value = keys subExpandedKeys.value = keys
} else if (keys[keys.length - 1].startsWith(subExpandedKeys.value[0])) { } else if (keys[keys.length - 1].startsWith(subExpandedKeys.value[0])) {
...@@ -584,7 +581,6 @@ function onSubExpand(keys: string[]) { ...@@ -584,7 +581,6 @@ function onSubExpand(keys: string[]) {
} else { } else {
subExpandedKeys.value = [keys[keys.length - 1]] subExpandedKeys.value = [keys[keys.length - 1]]
} }
// console.log('222', subExpandedKeys.value)
if (subExpandedKeys.value.length === 0) return if (subExpandedKeys.value.length === 0) return
const cur = subList.value.find((e) => e.key === subExpandedKeys.value[0]) const cur = subList.value.find((e) => e.key === subExpandedKeys.value[0])
setSub(cur) setSub(cur)
......
...@@ -23,6 +23,7 @@ import store from '@/store' ...@@ -23,6 +23,7 @@ import store from '@/store'
const showTag = ref(true) const showTag = ref(true)
const showReset = computed(() => store.state.showBasicInfo) const showReset = computed(() => store.state.showBasicInfo)
store.dispatch('getAuth')
</script> </script>
<style lang="stylus"> <style lang="stylus">
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
"baseUrl": ".", "baseUrl": ".",
"lib": ["esnext", "dom"], "lib": ["esnext", "dom"],
"paths": { "paths": {
"@/*": ["src/*"] "@/*": ["src/*"],
"@images/*": ["src/assets/images/*"]
} }
}, },
"include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"], "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment