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

上传功能完成

parent 7ef6e681
...@@ -69,6 +69,10 @@ const themeOverrides: GlobalThemeOverrides = { ...@@ -69,6 +69,10 @@ const themeOverrides: GlobalThemeOverrides = {
Card: { Card: {
borderRadius: '.06rem', borderRadius: '.06rem',
}, },
Upload: {
itemTextColorSuccess: '#3D7FE9',
itemTextColorError: '#E59B00',
},
Tag: { Tag: {
borderRadius: '.04rem', borderRadius: '.04rem',
colorPrimary: '#FCF4F5', colorPrimary: '#FCF4F5',
......
...@@ -10,12 +10,13 @@ const getCookie = (name: string): string | null => { ...@@ -10,12 +10,13 @@ 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/api/data/' BASE_URL = 'https://www.maicedata.com/collector/data/' // 生产环境
TOKEN = LZString.decompressFromEncodedURIComponent( TOKEN = LZString.decompressFromEncodedURIComponent(
getCookie('__DM_TOKEN__') || window.localStorage.getItem('dm_token_'), getCookie('__DM_TOKEN__') || window.localStorage.getItem('dm_token_'),
) )
break break
default: default:
// vite.config 代理 https://survey.maicedata.com/api/data/
BASE_URL = '/api' BASE_URL = '/api'
TOKEN = '91e315a9-b2a8-4950-97fa-9dbf84a230d6' TOKEN = '91e315a9-b2a8-4950-97fa-9dbf84a230d6'
} }
...@@ -35,5 +36,7 @@ export default { ...@@ -35,5 +36,7 @@ export default {
ATTACHMENT: '988fc63e-fa55-4729-851d-24c4355213f2', ATTACHMENT: '988fc63e-fa55-4729-851d-24c4355213f2',
TAG: '54344e11-c0d3-40d5-8f99-771066249328', TAG: '54344e11-c0d3-40d5-8f99-771066249328',
GET_AUTH: '988fc63e-fa55-4729-851d-24c4355213f2/storage/grant', GET_AUTH: '988fc63e-fa55-4729-851d-24c4355213f2/storage/grant',
GET_USER_ID: '/auth/user/bytoken', GET_USER_ID: 'https://www.maicedata.com/auth/user/bytoken',
USER: '3625616b-7f2c-449a-8306-101aac7b8b97',
ORG: 'b47ddc9a-0aa7-45a8-b1b6-6064f888d537',
} }
...@@ -6,7 +6,7 @@ import { api } from '@/ajax' ...@@ -6,7 +6,7 @@ import { api } from '@/ajax'
export default async function useAliOss(file: any) { export default async function useAliOss(file: any) {
const auth = (await useFetchAuth())?.token const auth = (await useFetchAuth())?.token
const client = new OSS({ const client = new OSS({
region: auth.region, region: 'oss-' + auth.region,
accessKeyId: auth.access_key_id, accessKeyId: auth.access_key_id,
accessKeySecret: auth.access_key_secret, accessKeySecret: auth.access_key_secret,
bucket: auth.bucket, bucket: auth.bucket,
...@@ -19,7 +19,7 @@ export default async function useAliOss(file: any) { ...@@ -19,7 +19,7 @@ export default async function useAliOss(file: any) {
fr.readAsArrayBuffer(file) fr.readAsArrayBuffer(file)
fr.onload = async (e) => { fr.onload = async (e) => {
const buffer = new OSS.Buffer(e.target && e.target.result) const buffer = new OSS.Buffer(e.target && e.target.result)
const key = `collector/${api.ACTIVITY}/huamu_${md5(buffer)}_${filename}` const key = `collector/${api.ATTACHMENT}/huamu_${md5(buffer)}_${filename}`
const res = await client.put(key, buffer) const res = await client.put(key, buffer)
resolve(res.url) resolve(res.url)
} }
......
...@@ -6,6 +6,7 @@ import { ...@@ -6,6 +6,7 @@ import {
HeadingLevel, HeadingLevel,
TextRun, TextRun,
ImageRun, ImageRun,
ExternalHyperlink,
} from 'docx' } from 'docx'
function createHeading(text: string): Paragraph { function createHeading(text: string): Paragraph {
...@@ -26,9 +27,9 @@ function createText(text: string): Paragraph { ...@@ -26,9 +27,9 @@ function createText(text: string): Paragraph {
}) })
} }
async function createImage(key: string, urls: string[]) { async function createImage(key: string, items: any[]) {
const blobs = await Promise.all( const blobs = await Promise.all(
urls.map(async (url) => await fetch(url).then((r: any) => r.blob())), items.map(async (item) => await fetch(item.url).then((r: any) => r.blob())),
) )
return new Paragraph({ return new Paragraph({
children: [ children: [
...@@ -46,6 +47,22 @@ async function createImage(key: string, urls: string[]) { ...@@ -46,6 +47,22 @@ async function createImage(key: string, urls: string[]) {
], ],
}) })
} }
function createLink(key: string, items: any[]) {
return new Paragraph({
children: [
new TextRun({ text: `${key}:` }),
...items.map(
(item: any) =>
new ExternalHyperlink({
link: item.url,
child: new TextRun({
text: decodeURIComponent(item.url.split('_').pop() || '未命名'),
}),
}),
),
],
})
}
async function createDocument(data: any[], labelKey: string) { async function createDocument(data: any[], labelKey: string) {
function arrayToString(e: unknown) { function arrayToString(e: unknown) {
...@@ -65,6 +82,7 @@ async function createDocument(data: any[], labelKey: string) { ...@@ -65,6 +82,7 @@ async function createDocument(data: any[], labelKey: string) {
if (key.startsWith('_')) return createText('') if (key.startsWith('_')) return createText('')
if (key.includes('照片')) if (key.includes('照片'))
return await createImage(key, item[key]) return await createImage(key, item[key])
if (key.includes('文件')) return createLink(key, item[key])
return createText(`${key}${arrayToString(item[key])}`) return createText(`${key}${arrayToString(item[key])}`)
}), }),
)), )),
......
...@@ -202,7 +202,6 @@ const getRooms = async (query: string) => { ...@@ -202,7 +202,6 @@ const getRooms = async (query: string) => {
) )
} }
const getFloors = async (data: any) => { const getFloors = async (data: any) => {
console.log('123', data)
return Promise.all( return Promise.all(
( (
await useFetchRoom({ await useFetchRoom({
......
...@@ -59,7 +59,6 @@ const props = defineProps({ ...@@ -59,7 +59,6 @@ const props = defineProps({
const trans = (val: string) => { const trans = (val: string) => {
return (val && val.replace(/(\w{3})\w*(\w{4})/, '$1******$2')) || '无' return (val && val.replace(/(\w{3})\w*(\w{4})/, '$1******$2')) || '无'
} }
console.log(dayjs().diff('1999-09-12', 'year'))
const tags = computed(() => { const tags = computed(() => {
const result: { type?: string; name?: string }[] = [] const result: { type?: string; name?: string }[] = []
const marker: string[] = props.data['标签'] || [] const marker: string[] = props.data['标签'] || []
......
This diff is collapsed.
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