Commit f7958952 authored by 郭铭瑶's avatar 郭铭瑶 🤘

10/13建议修改

parent 4e34714b
import { tokenIns } from '@/util/tokenUtil'
import { getCookie, setCookie } from '@/util/cookieUtil'
import { getCookie } from '@/util/cookieUtil'
let BASE_URL: string = ''
let MAP_CONFIG: { jsApiUrl: string; cssUrl: string } = {
jsApiUrl: '',
cssUrl: '',
}
// const TOKEN = getCookie('__DM_TOKEN__')
let TOKEN: string = ''
const mdtUser = getCookie('__DM_MDT_USER__')
const imperToken = getCookie('__DM_IMPER_TOKEN__')
const imperMdtUser = getCookie('__DM_IMPER_MDT_USER__')
switch (process.env.NODE_ENV) {
case 'production':
BASE_URL = 'https://www.maicedata.com/collector/data/' // 生产环境
// TOKEN = getToken()
case 'production': // 生产环境
BASE_URL = 'https://www.maicedata.com/collector/data/'
TOKEN = tokenIns.get()
MAP_CONFIG = {
jsApiUrl: 'https://hm.metrodata.cn/cehuiyuan/api418/arcgis_js_api/library/4.18/init.js',
jsApiUrl:
'https://hm.metrodata.cn/cehuiyuan/api418/arcgis_js_api/library/4.18/init.js',
cssUrl:
'https://hm.metrodata.cn/cehuiyuan/api418/arcgis_js_api/library/4.18/esri/css/main.css',
}
break
case 'sit':
BASE_URL = 'https://survey.maicedata.com/api/data/' // 测试环境(暂时部署在测绘院用)
// TOKEN = '91e315a9-b2a8-4950-97fa-9dbf84a230d6'
case 'sit': // 测试环境(暂时部署在测绘院用)
BASE_URL = 'https://survey.maicedata.com/api/data/'
TOKEN = '8d979525-f8ab-4c62-9d6b-a6eeb62c7455'
MAP_CONFIG = {
jsApiUrl: 'https://hm.metrodata.cn/cehuiyuan/api418/arcgis_js_api/library/4.18/init.js',
cssUrl: 'https://hm.metrodata.cn/cehuiyuan/api418/arcgis_js_api/library/4.18/esri/css/main.css',
jsApiUrl: 'http://10.108.3.41/arcgis_js_api/library/4.18/init.js',
cssUrl: 'http://10.108.3.41/arcgis_js_api/library/4.18/esri/css/main.css',
}
break
default:
BASE_URL = '/api' // vite.config 代理 https://survey.maicedata.com/api/data/
// TOKEN = '91e315a9-b2a8-4950-97fa-9dbf84a230d6'
// 本地开发环境
BASE_URL = '/api' // 由 vite.config 代理
TOKEN = '8d979525-f8ab-4c62-9d6b-a6eeb62c7455'
MAP_CONFIG = {
jsApiUrl: 'https://hm.metrodata.cn/cehuiyuan/api418/arcgis_js_api/library/4.18/init.js',
cssUrl: 'https://hm.metrodata.cn/cehuiyuan/api418/arcgis_js_api/library/4.18/esri/css/main.css',
jsApiUrl: 'http://10.108.3.41/arcgis_js_api/library/4.18/init.js',
cssUrl: 'http://10.108.3.41/arcgis_js_api/library/4.18/esri/css/main.css',
}
}
const TOKEN = tokenIns.get()
console.log(TOKEN, "ass")
export default {
TOKEN,
mdtUser,
......
......@@ -7,6 +7,7 @@ import {
TextRun,
ImageRun,
ExternalHyperlink,
AlignmentType,
} from 'docx'
function createHeading(text: string): Paragraph {
......@@ -14,6 +15,7 @@ function createHeading(text: string): Paragraph {
text: text,
heading: HeadingLevel.HEADING_1,
thematicBreak: true,
alignment: AlignmentType.CENTER,
})
}
......@@ -83,6 +85,8 @@ async function createDocument(data: any[], labelKey: string) {
if (key.startsWith('_')) return createText('')
if (key.includes('照片'))
return await createImage(key, item[key])
if (item[key]._recordIsPhoto)
return await createImage(key, item[key].photo)
if (key.includes('文件')) return createLink(key, item[key])
return createText(`${key}${arrayToString(item[key])}`)
}),
......
......@@ -72,10 +72,10 @@
<m-count class="count" :value="item.people" /> <span>人次</span>
<p>累计参与人次</p>
</div>
<div>
<!-- <div>
<m-count class="count" :value="item.ratio" /> <span>%</span>
<p>平均出席率</p>
</div>
</div> -->
</div>
</div>
</div>
......@@ -284,10 +284,10 @@ watch(
justify-content space-between
margin .03rem 0
>div
width 32%
width 49%
border .01rem solid $light-gray
border-radius .04rem
padding .03rem .05rem
padding .03rem .08rem
box-sizing border-box
.count
color $red
......
......@@ -16,6 +16,13 @@
size="small"
inline
>
<n-form-item label="活动内容描述" path="description">
<n-input
v-model:value="model.description"
placeholder="请输入活动描述"
clearable
/>
</n-form-item>
<n-form-item label="活动日期区间" path="dateStart">
<n-date-picker
v-model:value="model.dateStart"
......@@ -36,7 +43,7 @@
:is-date-disabled="disableDateEnd"
/>
</n-form-item>
<n-form-item label="出席率区间" path="rateStart">
<!-- <n-form-item label="出席率区间" path="rateStart">
<n-input-number
v-model:value="model.rateStart"
:show-button="false"
......@@ -56,7 +63,7 @@
>
<template #suffix>%</template>
</n-input-number>
</n-form-item>
</n-form-item> -->
<n-form-item label="标签类别" path="type">
<n-select
v-model:value="model.type"
......@@ -113,7 +120,7 @@ import { computed, ref, h, watch } from 'vue'
import NewActivityDrawer from './new-activity-drawer.vue'
import { Add } from '@vicons/ionicons5'
import dayjs from '@/util/dayjs'
import { NButton, NTag, useMessage } from 'naive-ui'
import { NButton, NTag, useMessage, NSpace } from 'naive-ui'
import { activity } from '@/util/tags'
import { useFetchActivity, useDeleteActivity } from '@/hooks/useFetch'
import useDebounce from '@/hooks/useDebounce'
......@@ -142,10 +149,11 @@ watch(
function clearData() {
model.value = {
description: null,
dateStart: null,
dateEnd: null,
rateStart: null,
rateEnd: null,
// rateStart: null,
// rateEnd: null,
type: null,
}
}
......@@ -170,6 +178,8 @@ watch(
() => model.value,
(cur) => {
const query: string[] = []
cur.description &&
query.push(`paths @ "活动内容描述" && string @ "${cur.description}"`)
cur.dateStart &&
query.push(
`paths @ "活动日期" && number >= ${+(cur.dateStart + '').slice(0, 10)}`,
......@@ -178,9 +188,9 @@ watch(
query.push(
`paths @ "活动日期" && number <= ${+(cur.dateEnd + '').slice(0, 10)}`,
)
cur.rateStart &&
query.push(`paths @ "出席率" && number >= ${cur.rateStart}`)
cur.rateEnd && query.push(`paths @ "出席率" && number <= ${cur.rateEnd}`)
// cur.rateStart &&
// 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)
},
......@@ -217,13 +227,20 @@ const columns = [
title: '标签类别',
key: '标签类别',
render(row: any) {
const type = row['标签类别']
? activity?.find((e) => e.name === row['标签类别'])?.type || 'default'
: 'default'
return row['标签类别']
? h(
let tagType = row['标签类别'] || []
if (typeof tagType === 'string') {
tagType = [tagType]
}
const types = tagType.map(
(tag: string) =>
activity?.find((e) => e.name === tag)?.type || 'default',
)
return h(NSpace, [
...types.map((type, i) =>
h(
NTag,
{
key: i,
size: 'small',
type: type as
| 'default'
......@@ -234,8 +251,25 @@ const columns = [
| 'warning',
},
{ default: () => row['标签类别'] },
)
: ''
),
),
])
// return row['标签类别']
// ? h(
// NTag,
// {
// size: 'small',
// type: type as
// | 'default'
// | 'error'
// | 'primary'
// | 'info'
// | 'success'
// | 'warning',
// },
// { default: () => row['标签类别'] },
// )
// : ''
},
},
{ title: '活动地址', key: '活动地址' },
......@@ -347,22 +381,22 @@ const disableDateEnd = (ts: number) => {
}
return !cur.isAfter(start) || !cur.isBefore(end)
}
const checkRateStart = (val: number) => {
const start = 0
let end = 100
if (model.value.rateEnd) {
end = model.value.rateEnd
}
return val >= start && val <= end
}
const checkRateEnd = (val: number) => {
let start = 0
const end = 100
if (model.value.rateStart) {
start = model.value.rateStart
}
return val >= start && val <= end
}
// const checkRateStart = (val: number) => {
// const start = 0
// let end = 100
// if (model.value.rateEnd) {
// end = model.value.rateEnd
// }
// return val >= start && val <= end
// }
// const checkRateEnd = (val: number) => {
// let start = 0
// const end = 100
// if (model.value.rateStart) {
// start = model.value.rateStart
// }
// return val >= start && val <= end
// }
</script>
<style lang="stylus" scoped>
......
......@@ -42,20 +42,39 @@
label-placement="top"
>
<n-grid :cols="24" :x-gap="12">
<n-form-item-gi :span="24" label="标签类别" path="type">
<n-space v-if="mode === 'view'">
<!-- {{
typeOptions.find((e) => e.value === basicData.type)?.label
}} -->
<n-tag
v-for="tag in basicData.type"
:key="tag"
:type="getTagType(tag)"
size="small"
>
{{ tag }}
</n-tag>
</n-space>
<n-select
v-else
v-model:value="basicData.type"
multiple
:options="typeOptions"
/>
</n-form-item-gi>
<n-form-item-gi :span="12" label="活动名称" path="name">
<p v-if="mode === 'view'">{{ basicData.name }}</p>
<n-input v-else v-model:value="basicData.name" />
</n-form-item-gi>
<n-form-item-gi :span="12" label="标签类别" path="type">
<n-form-item-gi :span="12" label="活动日期" path="date">
<p v-if="mode === 'view'">
{{
typeOptions.find((e) => e.value === basicData.type)?.label
}}
{{ dayjs(basicData.date).format('YYYY-MM-DD') }}
</p>
<n-select
<n-date-picker
v-else
v-model:value="basicData.type"
:options="typeOptions"
v-model:value="basicData.date"
style="width: 100%"
/>
</n-form-item-gi>
<n-form-item-gi
......@@ -77,16 +96,6 @@
filterable
/>
</n-form-item-gi>
<n-form-item-gi :span="12" label="活动日期" path="date">
<p v-if="mode === 'view'">
{{ dayjs(basicData.date).format('YYYY-MM-DD') }}
</p>
<n-date-picker
v-else
v-model:value="basicData.date"
style="width: 100%"
/>
</n-form-item-gi>
<n-form-item-gi
:span="24"
:label="`活动地址${
......@@ -97,7 +106,7 @@
path="address"
>
<p v-if="mode === 'view'">{{ basicData.address }}</p>
<n-input v-else v-model:value="basicData.address" />
<n-input v-else v-model:value="basicData.address" clearable />
</n-form-item-gi>
</n-grid>
</n-form>
......@@ -131,6 +140,7 @@
</n-input-number>
</n-form-item-gi>
<n-form-item-gi
v-if="mode !== 'view' || memberData.excludeCount"
:span="12"
label="不计入参与活动党员人数"
path="excludeCount"
......@@ -147,6 +157,7 @@
</n-input-number>
</n-form-item-gi>
<n-form-item-gi
v-if="mode !== 'view' || memberData.fileType"
:span="24"
:label="`电子表格或签到照片${
mode === 'view' ? '' : '(大小20M以内)'
......@@ -240,6 +251,7 @@
>
<n-input
v-model:value="detailData.attachment"
placeholder="请输入活动内容描述(800字以内)"
type="textarea"
/>
</n-form-item-gi>
......@@ -365,6 +377,9 @@ const typeOptions = computed(() => {
value: item.name,
}))
})
const getTagType = (tag: string) => {
return activity?.find((e) => e.name === tag)?.type || 'default'
}
const fileOptions = [
{ label: '电子表格(docx、doc、xlsx、xls、csv、txt)', value: 'file' },
{ label: '签到照片(jpg、jpeg、png、img)', value: 'photo' },
......@@ -461,6 +476,7 @@ const rules: FormRules = {
},
type: {
required: true,
type: 'array',
trigger: ['blur', 'change'],
message: '请选择标签类别',
},
......@@ -475,11 +491,11 @@ const rules: FormRules = {
trigger: ['blur', 'change'],
message: '请选择活动日期',
},
address: {
required: true,
trigger: ['blur', 'input'],
message: '请输入活动地址',
},
// address: {
// required: true,
// trigger: ['blur', 'input'],
// message: '请输入活动地址',
// },
count: [
{
type: 'number',
......@@ -495,12 +511,12 @@ const rules: FormRules = {
},
],
excludeCount: [
{
type: 'number',
required: true,
trigger: ['blur', 'input'],
message: '请输入不计入参与活动党员人数',
},
// {
// type: 'number',
// required: true,
// trigger: ['blur', 'input'],
// message: '请输入不计入参与活动党员人数',
// },
{
type: 'number',
validator: (_, val) => checkMemberCount(val),
......@@ -514,52 +530,61 @@ const rules: FormRules = {
trigger: ['blur', 'input'],
},
],
fileType: [
// fileType: [
// {
// required: true,
// trigger: ['blur', 'change'],
// message: '请选择上传类型',
// },
// {
// validator: (_, val) => {
// if (val !== 'file') return true
// if (
// !memberData.value.attachment ||
// memberData.value.attachment.length === 0
// ) {
// return false
// }
// return true
// },
// message: '请上传附件',
// },
// {
// validator: (_, val) => {
// if (val !== 'photo') return true
// if (
// !memberData.value.attachmentPhoto ||
// memberData.value.attachmentPhoto.length === 0
// ) {
// return false
// }
// return true
// },
// message: '请上传签到照片',
// },
// ],
describeType: [
{
required: true,
trigger: ['blur', 'change'],
message: '请选择上传类型',
},
{
validator: (_, val) => {
if (val !== 'file') return true
if (
!memberData.value.attachment ||
memberData.value.attachment.length === 0
) {
return false
}
return true
},
message: '请上传附件',
message: '请选择描述类型',
},
{
validator: (_, val) => {
if (val !== 'photo') return true
if (
!memberData.value.attachmentPhoto ||
memberData.value.attachmentPhoto.length === 0
) {
return false
}
if (val !== 'text') return true
if (!detailData.value.attachment) return false
return true
},
message: '请上传签到照片',
},
],
describeType: [
{
required: true,
trigger: ['blur', 'change'],
message: '请选择描述类型',
message: '请输入活动内容描述',
},
{
validator: (_, val) => {
if (val !== 'text') return true
if (!detailData.value.attachment) return false
const data = detailData.value.attachment
if (data.length < 50 || data.length > 800) return false
return true
},
message: '请输入活动内容描述',
message: '请输入50至800字的活动内容描述',
},
{
validator: (_, val) => {
......@@ -606,7 +631,7 @@ const submit = () => {
标签类别: type,
党组织名称: orgName,
活动日期: +(date + '').slice(0, 10), // 截掉10位后的0,不然这接口会认为不是时间戳
活动地址: address,
活动地址: address || defaultAddress.value,
实际参与人数: count,
不计入参与活动党员人数: excludeCount,
活动照片: photoList?.map((item: any) => item.url) || [],
......@@ -618,7 +643,7 @@ const submit = () => {
? 0
: getPercent(
Math.round(
(count / (totalPerson.value - excludeCount)) * 100,
(count / (totalPerson.value - (excludeCount || 0))) * 100,
),
),
}
......@@ -770,17 +795,19 @@ async function onFileChange(options: any, type: string) {
const totalPerson = ref(0)
const location = ref<number[]>([])
const orgCode = ref('')
const defaultAddress = ref('')
async function getOrgInfo(name: string) {
if (!name) return
const res = (
await useFetchOrg({
keys: '党员数量,上海2000经度,上海2000纬度,党组织编号',
keys: '党员数量,上海2000经度,上海2000纬度,党组织编号,党组织地址',
q: `paths @ "党组织名称" && string == "${name}"`,
})
)?.[0]
totalPerson.value = res?.['党员数量'] || 0
location.value = [res?.['上海2000经度'] || 0, res?.['上海2000纬度'] || 0]
orgCode.value = res?.['党组织编号'] || ''
defaultAddress.value = res?.['党组织地址'] || ''
}
watch(
() => basicData.value.orgName,
......@@ -794,62 +821,27 @@ function checkMemberCount(val: number) {
return val >= 0 && val <= totalPerson.value
}
const handleExport = async () => {
const { name, type, orgName, date, address } = basicData.value
const { count, excludeCount, attachment, attachmentPhoto } = memberData.value
const { name, date } = basicData.value
const {
attachment: detailAttachment,
attachmentPhoto: detailAttachmentPhoto,
photoList,
} = detailData.value
const data = [
{
活动名称: name,
标签类别: type,
党组织名称: orgName,
活动日期: dayjs(date).format('YYYY-MM-DD'), // 截掉10位后的10,不然这接口会认为不是时间戳
活动地址: address,
},
{
实际参与人数: count,
不计入参与活动党员人数: excludeCount,
出席率:
totalPerson.value === excludeCount
? '0%'
: getPercent(
Math.round((count / (totalPerson.value - excludeCount)) * 100),
) + '%',
},
{
活动内容描述: detailAttachment,
活动照片: photoList,
},
]
if (attachment && attachment.length > 0) {
data[1]['签到表文件'] = attachment
}
if (attachmentPhoto && attachmentPhoto.length > 0) {
data[1]['签到表照片'] = attachmentPhoto
}
if (detailAttachment) {
data[2]['活动内容描述'] = detailAttachment
const data = {
活动名称: name,
活动日期: dayjs(date).format('YYYY-MM-DD'), // 截掉10位后的10,不然这接口会认为不是时间戳
活动记录: detailAttachment,
活动照片: photoList,
}
if (detailAttachmentPhoto && detailAttachmentPhoto.length > 0) {
data[2]['台账记录照片'] = detailAttachmentPhoto
data['活动记录'] = { _recordIsPhoto: true, photo: detailAttachmentPhoto }
}
await useExportDocx(
[
{
_title: '基本信息',
...data[0],
},
{
_title: '人员参与情况',
...data[1],
},
{
_title: '活动详情',
...data[2],
_title: '会议及活动记录',
...data,
},
],
'_title',
......
......@@ -24,7 +24,7 @@ export default defineConfig({
port: 3001,
proxy: {
'/api': {
target: 'https://survey.maicedata.com/api/data/',
target: 'https://www.maicedata.com/collector/data/',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
},
......
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