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

试打包

parent 06e2b1f1
......@@ -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'
......
......@@ -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)
}
})
......
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,
......
......@@ -14,7 +14,8 @@ declare module '*.png'
declare module '*.jpg'
declare module '*.jpeg'
declare module '*.gif'
declare module '*.svg'
declare const LZString: {
decompressFromEncodedURIComponent: any
}
\ No newline at end of file
}
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),
......
......@@ -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
},
......
export default {
showLoading: false,
auth: {
region: '',
access_key_id: '',
access_key_secret: '',
bucket: '',
security_token: '',
},
showBasicInfo: true,
showFilterDrawer: false,
showActivityDrawer: false,
......
......@@ -26,9 +26,9 @@
:is-date-disabled="disableDateStart"
/>
</n-form-item>
<n-form-item path="dateEne">
<n-form-item path="dateEnd">
<n-date-picker
v-model:value="model.dateEne"
v-model:value="model.dateEnd"
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 @ "出席率" && integer >= ${cur.rateStart}`)
cur.rateEnd && query.push(`paths @ "出席率" && integer <= ${cur.rateEnd}`)
query.push(`paths @ "出席率" && number >= ${cur.rateStart}`)
cur.rateEnd && query.push(`paths @ "出席率" && number <= ${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['标签类别']
......
......@@ -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>
......
......@@ -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 请求提交数据
console.log(basicData.value, memberData.value, detailData.value)
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>
......
......@@ -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: {
......
......@@ -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)
......
......@@ -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">
......
......@@ -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"],
......
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