From d015da898dc22c8492d69e72031c8a3f907359bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=98=B1=E8=BE=BE?= Date: Sun, 16 Mar 2025 14:43:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(api):=20=E6=96=B0=E5=A2=9E=E9=80=9A?= =?UTF-8?q?=E7=94=A8=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 uploadFileWidthSn 和 uploadFileWidthSnForAnswer 方法用于上传文件 - 实现 getOssInfo 方法获取 OSS 信息 - 添加 cosUpload3D 和 cosUpload 方法上传文件到 COS- 实现 docuHousecosUpload 方法上传文件到阿里云和文档库 - 优化文件命名和错误处理 --- components.d.ts | 13 +- src/api/common.js | 147 ++++++++++++++++++ src/api/upload/index.js | 8 + src/components/contenteditable.vue | 120 +++++++++++--- src/fonts/moblie/demo.css | 4 +- src/fonts/moblie/iconfont.css | 16 ++ src/fonts/moblie/iconfont.woff | Bin 4296 -> 4752 bytes src/layouts/config3d.constant.js | 2 +- src/layouts/logic.js | 60 +++---- src/layouts/utils.js | 68 ++++---- src/utils/txyunCosUpLoad.js | 56 +++++++ .../Design/components/Questions/Choice.vue | 2 + .../components/Questions/SignQuestion.vue | 10 +- src/views/Survey/views/Create/Index.vue | 22 +-- src/views/Survey/views/Publish/Index.vue | 53 ++++--- 15 files changed, 462 insertions(+), 119 deletions(-) create mode 100644 src/api/common.js create mode 100644 src/api/upload/index.js create mode 100644 src/utils/txyunCosUpLoad.js diff --git a/components.d.ts b/components.d.ts index bc1c037..bdaf31a 100644 --- a/components.d.ts +++ b/components.d.ts @@ -2,15 +2,21 @@ // @ts-nocheck // Generated by unplugin-vue-components // Read more: https://github.com/vuejs/core/pull/3399 -export {}; +export {} /* prettier-ignore */ declare module 'vue' { export interface GlobalComponents { Contenteditable: typeof import('./src/components/contenteditable.vue')['default'] + ElButton: typeof import('element-plus/es')['ElButton'] + ElDropdown: typeof import('element-plus/es')['ElDropdown'] + ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem'] + ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu'] ElInput: typeof import('element-plus/es')['ElInput'] ElOption: typeof import('element-plus/es')['ElOption'] ElSelect: typeof import('element-plus/es')['ElSelect'] + ElSpace: typeof import('element-plus/es')['ElSpace'] + ElText: typeof import('element-plus/es')['ElText'] RichText: typeof import('./src/components/RichText.vue')['default'] RouterLink: typeof import('vue-router')['RouterLink'] RouterView: typeof import('vue-router')['RouterView'] @@ -32,8 +38,13 @@ declare module 'vue' { VanRadio: typeof import('vant/es')['Radio'] VanRadioGroup: typeof import('vant/es')['RadioGroup'] VanRow: typeof import('vant/es')['Row'] + VanSearch: typeof import('vant/es')['Search'] VanStepper: typeof import('vant/es')['Stepper'] VanSwitch: typeof import('vant/es')['Switch'] + VanTab: typeof import('vant/es')['Tab'] + VanTabbar: typeof import('vant/es')['Tabbar'] + VanTabbarItem: typeof import('vant/es')['TabbarItem'] + VanTabs: typeof import('vant/es')['Tabs'] YLCascader: typeof import('./src/components/YLCascader.vue')['default'] YLInput: typeof import('./src/components/YLInput.vue')['default'] YLPicker: typeof import('./src/components/YLPicker.vue')['default'] diff --git a/src/api/common.js b/src/api/common.js new file mode 100644 index 0000000..fc4dfe9 --- /dev/null +++ b/src/api/common.js @@ -0,0 +1,147 @@ +import request from '@/utils/request'; +import createCOS from '@/utils/txyunCosUpLoad.js'; +import { uploadDocumentFile } from './upload/index.js'; +import router from '../router/index'; +import { computed } from 'vue'; +import { shrinkImage } from 'shrinkpng'; +const sn = computed(() => router.currentRoute.value.query.sn || 'default'); +export default class CommonApi { + static uploadFileWidthSn(file, sn) { + const formData = new FormData(); + formData.append('file', file); + formData.append('sn', sn || ''); + + return request({ + url: '/console/upload_file', + method: 'post', + data: formData + }); + } + static uploadFileWidthSnForAnswer(file, sn) { + const formData = new FormData(); + formData.append('file', file); + + return request({ + url: `/answer/upload_file/${sn}`, + method: 'post', + data: formData + }); + } + /** OssInfo */ + static getOssInfo() { + return request({ + url: '/console/files/credentials' + }); + } + static async cosUpload3DCompress(file, quality = 20) { + const _file = await shrinkImage(file, { quality }); + return await this.cosUpload3D(_file); + } + static async cosUpload3D(file, defaultName = '') { + let name = defaultName?.replace?.(/[\s+]/g, '_') || ''; + + const getRandomFileName = () => { + return `3D/upload/${new Date().getTime()}_${Math.floor(Math.random() * 1000)}`; + }; + + name = name || getRandomFileName(); + const { data } = await CommonApi.getOssInfo(); + const param = { + region: data.Region, + host: data.Host, + sessionToken: data.sessionToken, + tmpSecretId: data.tmpSecretId, + tmpSecretKey: data.tmpSecretKey, + bucket: data.Bucket, + startTime: data.startTime, + expiredTime: data.expiredTime, + name: `${data.prefix}/${name}`, + file + }; + + try { + const location = await createCOS(param); + return { + url: `https://${location}`, + name + }; + } catch (error) { + return { + url: '', + name: '' + }; + } + } + /** + * 上传文件 + * @param {文件file} file + * @returns {url:"",name:'fileName'} + */ + static async cosUpload(file, fileName) { + let name = fileName?.replace?.(/[\s+]/g, '_') || ''; + + const getRandomFileName = (name) => { + return `survey/${sn.value}/${new Date().getTime()}-${Math.floor(Math.random() * 1000)}-${name}`; + }; + /* eslint-disable no-useless-escape */ + const reg = /\\|\/|\?|\?|\*|"|“|”|'|‘|’|<|>|{|}|\[|\]|\【|\】|:|:|、|\^|\$|!|~|`|\s|\+/g; + name = + name || + getRandomFileName(file?.name?.replace(reg, '') ?? '' ?? `${new Date().getTime()}.png`); + const res = await CommonApi.getOssInfo(); + /* eslint-enable no-useless-escape */ + + const { data } = res.data; + const param = { + region: data.Region, + host: data.Host, + sessionToken: data.sessionToken, + tmpSecretId: data.tmpSecretId, + tmpSecretKey: data.tmpSecretKey, + bucket: data.Bucket, + startTime: data.startTime, + expiredTime: data.expiredTime, + name: `${data.prefix}/${name}`, + file + }; + try { + const location = await createCOS(param); + return { + url: `https://${location}`, + name + }; + } catch (error) { + return { + url: '', + name: '' + }; + } + } + /** + * 上传文件到阿里云和文档库 + * @param {文件file} file + * @param {问卷id} sn + * @param {1=问卷设计,2=数据分析,3=问卷预览,4=数据明细,5=图表分析,6=高级分析,7=市场模拟} importType + * @returns {url:"",name:'fileName'} + */ + static async docuHousecosUpload(file, sn, importType, startFileName = 'survey') { + // eslint-disable-next-line standard/no-callback-literal + const reg = /\\|\/|\?|?|\*|"|“|”|'|‘|’|<|>|{|}|\[|\]|【|】|:|:|、|\^|\$|!|~|`|\s|\+/g; + + // eslint-disable-next-line standard/no-callback-literal + const fileName = `${startFileName}/${new Date().getTime()}_${Math.floor(Math.random() * 1000)}_${ + file?.name?.replace(reg, '') ?? '' ?? `${new Date().getTime()}.png` + }`; + try { + const result = await this.cosUpload(file, fileName); + uploadDocumentFile({ + url: JSON.stringify([{ name: file.name, url: result.url, size: file.size }]), + parent_sn: sn?.value || sn, + import_type: importType || 1 + }); + return result; + } catch (error) { + // error + } + } +} diff --git a/src/api/upload/index.js b/src/api/upload/index.js new file mode 100644 index 0000000..2d06e5e --- /dev/null +++ b/src/api/upload/index.js @@ -0,0 +1,8 @@ +import request from '@/utils/request.js'; +export function uploadDocumentFile(data) { + return request({ + url: `/console/document_import`, + method: 'post', + data + }); +} diff --git a/src/components/contenteditable.vue b/src/components/contenteditable.vue index 67418c6..469cdca 100644 --- a/src/components/contenteditable.vue +++ b/src/components/contenteditable.vue @@ -1,9 +1,11 @@ diff --git a/src/fonts/moblie/demo.css b/src/fonts/moblie/demo.css index 18e8077..12ec742 100644 --- a/src/fonts/moblie/demo.css +++ b/src/fonts/moblie/demo.css @@ -4,11 +4,11 @@ src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834'); src: url('https://at.alicdn.com/t/font_985780_km7mi63cihi.eot?t=1545807318834#iefix') - format('embedded-opentype'), + format('embedded-opentype'), url('https://at.alicdn.com/t/font_985780_km7mi63cihi.woff?t=1545807318834') format('woff'), url('https://at.alicdn.com/t/font_985780_km7mi63cihi.ttf?t=1545807318834') format('truetype'), url('https://at.alicdn.com/t/font_985780_km7mi63cihi.svg?t=1545807318834#iconfont') - format('svg'); + format('svg'); } .logo { diff --git a/src/fonts/moblie/iconfont.css b/src/fonts/moblie/iconfont.css index 2ad02d0..68b34b2 100644 --- a/src/fonts/moblie/iconfont.css +++ b/src/fonts/moblie/iconfont.css @@ -14,6 +14,22 @@ -moz-osx-font-smoothing: grayscale; } +.mobilefont-jiacu::before { + content: '\e71d'; +} + +.mobilefont-qingxie::before { + content: '\e71e'; +} + +.mobilefont-xiahuaxian::before { + content: '\e720'; +} + +.mobilefont-tupian::before { + content: '\e730'; +} + .mobilefont-del1::before { content: '\e637'; } diff --git a/src/fonts/moblie/iconfont.woff b/src/fonts/moblie/iconfont.woff index c21f7d0d95bed6a29c30e6549f90a4d52c321797..ff340bbf5f8d52b5afe65d7f770723d409b4f0fe 100644 GIT binary patch delta 4289 zcmV;y5I*n7A&?~$cTYw}00961000t@01E&B0011+krY3F*kf&BZ~y=ShyVZqDF6Ti zZ1Bo{8fR>IW&i*Jv;Y7M@Bjc49QqxRl4xaNWB>pUqyPW_F#rGnHY=MYd}wH8VE_OR z*Z=?kAOHXWBnV>!9%yZJcmMzo_y7O^7XSbNY;5-b{%mh!VE_OS5C8xGH~;_uI5`?U zC~aYQZ~y={5J&(303QGV03ZP}0HtnWZDjxe5NH4Z0Zae@0)LKUn_O^jb94Xz5wrjR z0NVfn0Xmo=7{ikY0YU*}lS=_Pe}#PwgLs_X(>rd$Ko|tzF|WMH`{f{EQKUr3fk-rw z5MAy-#Q``&I?llnxC3{YrH(|2oLP?x8le816Py)px_dbK z*H@z1xDAiC_o@LcJm413xI?NHHSvN=+~Win=-?VxIK>Ul^v#-9tQF!>KWP17Hvjc% z$6NAQy>()mriv<8Q*FV4smfq(syFy%sysL}WdM#W?k|ol?nh2c34v2nR^Z%}8n`g! z2QE!Xf-5WMxi+N>ZcI6Ye>+p+;NFxySeSMJLf7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GKoJxm4gj}t2ZVT>V_{%m zU?B&$0&(I0fB4h@0Bj-yPyhe`O#lD@LI7?70s&e9paL2Kegf75Rs(PY?gSD9=mlm4 z>IN0umRMnp4W96fEnZCS=zUjtV(+3<2}o&|rCCa+LAdHkHL%aDbM@J} zAbYt?j`7wKJ9{8rG%Yo!w0!+F this[key] == item); + return Object.keys(this).some((key) => this[key] === item); } }; diff --git a/src/layouts/logic.js b/src/layouts/logic.js index 7ff8ce3..5c46026 100644 --- a/src/layouts/logic.js +++ b/src/layouts/logic.js @@ -368,39 +368,39 @@ export function isCross(range1, range2) { const isSibling = isLeft || isRight; // 逻辑包含循环 - const contain = - (isPlainSequence && - (((isNullish(start2) || isSequence(judge, start2, start1)) && - (isNullish(end2) || isSequence(judge, end2, start1))) || - ((isNullish(start2) || isSequence(start1, start2, end1)) && - (isNullish(end2) || isSequence(start1, end2, end1))))) || - (!isPlainSequence && - (judge < start1 - ? ((isNullish(start2) || isSequence(judge, start2, start1)) && - (isNullish(end2) || isSequence(judge, end2, start1))) || - ((isNullish(start2) || isSequence(start1, start2, end1)) && - (isNullish(end2) || isSequence(start1, end2, end1))) - : ((isNullish(start2) || isSequence(start1, start2, judge)) && - (isNullish(end2) || isSequence(start1, end2, judge))) || - ((isNullish(start2) || isSequence(judge, start2, end1)) && - (isNullish(end2) || isSequence(judge, end2, end1))))); + const contain + = (isPlainSequence + && (((isNullish(start2) || isSequence(judge, start2, start1)) + && (isNullish(end2) || isSequence(judge, end2, start1))) + || ((isNullish(start2) || isSequence(start1, start2, end1)) + && (isNullish(end2) || isSequence(start1, end2, end1))))) + || (!isPlainSequence + && (judge < start1 + ? ((isNullish(start2) || isSequence(judge, start2, start1)) + && (isNullish(end2) || isSequence(judge, end2, start1))) + || ((isNullish(start2) || isSequence(start1, start2, end1)) + && (isNullish(end2) || isSequence(start1, end2, end1))) + : ((isNullish(start2) || isSequence(start1, start2, judge)) + && (isNullish(end2) || isSequence(start1, end2, judge))) + || ((isNullish(start2) || isSequence(judge, start2, end1)) + && (isNullish(end2) || isSequence(judge, end2, end1))))); // 循环存在封闭区间,并且循环包含逻辑 - const contained = - !isNullish(start2) && - !isNullish(end2) && + const contained + = !isNullish(start2) + && !isNullish(end2) // [judge, start1, end1]; - ((isPlainSequence && start2 <= judge && end1 <= end2) || + && ((isPlainSequence && start2 <= judge && end1 <= end2) // [judge, start1, end1]; // [start1, judge, end1]; - (!isPlainSequence && start2 <= start1 && start2 <= judge && end1 <= end2)); + || (!isPlainSequence && start2 <= start1 && start2 <= judge && end1 <= end2)); // 循环不存在封闭区间 - const unCircled = - (!isNullish(start2) && - isNullish(end2) && - ((isPlainSequence && start2 === judge) || (!isPlainSequence && judge < start1) + const unCircled + = (!isNullish(start2) + && isNullish(end2) + && ((isPlainSequence && start2 === judge) || (!isPlainSequence && judge < start1) ? start2 === judge - : start2 === start1)) || - (isNullish(start2) && !isNullish(end2) && end2 === end1); + : start2 === start1)) + || (isNullish(start2) && !isNullish(end2) && end2 === end1); return !(isSibling || contain || contained || unCircled); } @@ -420,13 +420,13 @@ function isSequence(s1, s2, s3, equal) { * @param store */ export function updateNewQuestionsByLoopingEffect(quesSaveParam, store) { - const { questionInfoBeforeModified = {}, questionInfo = {} } = - JSON.parse(JSON.stringify(store.state.common)) || {}; + const { questionInfoBeforeModified = {}, questionInfo = {} } + = JSON.parse(JSON.stringify(store.state.common)) || {}; const oldPages = questionInfoBeforeModified.survey.pages; const newQuestions = questionInfo.questions; const newPages = questionInfo.survey.is_one_page_one_question - ? questionInfo.questions.filter((i) => i.question_index).map((i, idx) => [i.question_index]) + ? questionInfo.questions.filter((i) => i.question_index).map((i) => [i.question_index]) : questionInfo.survey.pages; const cycles = questionInfo.cycle_pages || []; diff --git a/src/layouts/utils.js b/src/layouts/utils.js index 8df15ec..7c44672 100644 --- a/src/layouts/utils.js +++ b/src/layouts/utils.js @@ -33,7 +33,9 @@ function showModal(options) { .then(() => { // confirm(); }) - .catch(() => {}); + .catch(() => { + // catch(); + }); } /** @@ -41,13 +43,13 @@ function showModal(options) { * @param {*} data * @returns */ -const canPlanetPublishPSM = function (data) { +const canPlanetPublishPSM = function(data) { let isFb = true; let message = ''; let title = '题目设置未完成'; const incompleteQuestionList = []; - data.questions && - data.questions.forEach((s) => { + data.questions + && data.questions.forEach((s) => { if (s.question_type === 101 && s.config.price_gradient.length <= 0) { isFb = false; message = 'psm题目未完成设置,请设置价格区间后投放'; @@ -72,15 +74,15 @@ const canPlanetPublishPSM = function (data) { * @param {*} data * @returns */ -const canPlanetPublishMxdAndHotArea = function (data) { +const canPlanetPublishMxdAndHotArea = function(data) { let isFb = true; let message = ''; const qSteams = []; const incompleteQuestionList = []; let type = 0; let title = '题目设置未完成'; - data.questions && - data.questions.forEach((s) => { + data.questions + && data.questions.forEach((s) => { if (s.question_type === 105 && s.config.design_version <= 0) { isFb = false; message = 'maxdiff题目未完成设置,请生成设计后投放'; @@ -119,21 +121,23 @@ const canPlanetPublishMxdAndHotArea = function (data) { * @param {*} data * @returns */ -const canPlanetPublish3D = function (data) { +const canPlanetPublish3D = function(data) { { let canFB = true; let message = ''; const qSteams = []; let title = ''; - data.questions && - data.questions.forEach((s) => { + data.questions + && data.questions.forEach((s) => { if (QUESTION_TYPE.contains(s.question_type)) { try { if (s.config.is_three_dimensions && !s.config.scene) { canFB = false; qSteams.push(`(${s.title})`); } - } catch (error) {} + } catch (error) { + // eslint-disable-next-line no-eval + } } }); @@ -154,15 +158,15 @@ const canPlanetPublish3D = function (data) { let message = ''; const qSteams = []; let title = ''; - data.questions && - data.questions.forEach((s) => { + data.questions + && data.questions.forEach((s) => { if (QUESTION_TYPE.contains(s.question_type)) { try { if (s.config.is_three_dimensions && s.config.is_binding_goods) { const wares = []; const _sceneInformation = s.config.scene_information; - const sceneInformation = - typeof _sceneInformation === 'string' + const sceneInformation + = typeof _sceneInformation === 'string' ? JSON.parse(_sceneInformation) : _sceneInformation; sceneInformation.shelves.forEach((shelf) => { @@ -174,7 +178,10 @@ const canPlanetPublish3D = function (data) { const options = s.options.flat(); s.associate.forEach((ass) => { - const question = data.questions.find((q) => q.question_index == ass.question_index); + // eslint-disable-next-line no-eval + const question = data.questions.find( + (q) => q.question_index === ass.question_index + ); if (!question) return; options.push(...question.options.flat()); }); @@ -184,7 +191,9 @@ const canPlanetPublish3D = function (data) { qSteams.push(`(${s.title})`); } } - } catch (error) {} + } catch (error) { + // error + } } }); @@ -207,14 +216,14 @@ const canPlanetPublish3D = function (data) { * @param {*} data * @returns */ -const canPlanetPublishImage = function (data) { +const canPlanetPublishImage = function(data) { { let canFB = true; let message = ''; const qSteams = []; let title = ''; - data.questions && - data.questions.forEach((s) => { + data.questions + && data.questions.forEach((s) => { if (s.question_type === 13) { try { if (s.options.length <= 0 || s.options.some((y) => y.length <= 0)) { @@ -284,9 +293,10 @@ function canPublishRandom(data, publishType) { const publishStr = ['', '预览', '投放'][publishType] || '投放'; const errors = []; + // eslint-disable-next-line no-eval const randomList = data?.survey?.group_pages || []; - randomList.forEach((random, randomIndex) => { + randomList.forEach((random) => { const list = random.list || []; // 每一个随机,至少要有两个随机题组 @@ -308,8 +318,8 @@ function canPublishRandom(data, publishType) { if (!isValidated) { errors.push({ message: - field.message || - `请填写"${random.title}"中第${index + 1}组"随机题组"的"${field.name}"` + field.message + || `请填写"${random.title}"中第${index + 1}组"随机题组"的"${field.name}"` }); } }); @@ -369,11 +379,11 @@ function isLoopingLogicValid(data, publishType) { if ( (data?.cycle_pages || []).every((i) => { return ( - i.question_index && - i.relation_type !== undefined && - i.relation_type !== null && - i.first_page && - i.last_page + i.question_index + && i.relation_type !== undefined + && i.relation_type !== null + && i.first_page + && i.last_page ); }) ) { @@ -397,7 +407,7 @@ function isLoopingLogicValid(data, publishType) { * @param sn * @param publishType undefined投放;null投放;0投放;1预览;2投放;3测试 */ -export const canPlanetPublish = async function (sn, publishType) { +export const canPlanetPublish = async function(sn, publishType) { const parsedPublishType = !publishType ? 2 : publishType; const num = window.location.href.indexOf('code='); let code; diff --git a/src/utils/txyunCosUpLoad.js b/src/utils/txyunCosUpLoad.js new file mode 100644 index 0000000..f4b9185 --- /dev/null +++ b/src/utils/txyunCosUpLoad.js @@ -0,0 +1,56 @@ +// const COS = require('cos-js-sdk-v5'); +import COS from 'cos-js-sdk-v5'; +/** + * + * @param {腾讯云的pramas} data + * @returns + */ +export default function createCOS(data) { + const { + bucket, + host, + region, + sessionToken, + tmpSecretId, + tmpSecretKey, + startTime, + expiredTime, + name, + file + } = data; + + const config = { + Region: region, + Host: host, + Bucket: bucket, + Key: name, + Body: file, + onProgress: (progressData) => { + console.log(progressData); + } + }; + const client = new COS({ + getAuthorization: (options, callback) => { + // eslint-disable-next-line standard/no-callback-literal + callback({ + TmpSecretId: tmpSecretId, + TmpSecretKey: tmpSecretKey, + SecurityToken: sessionToken, + // 建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误 + StartTime: startTime, // 时间戳,单位秒,如:1580000000 + ExpiredTime: expiredTime + }); + } + // eslint-enable standard/no-callback-literal + }); + return new Promise((resolve, reject) => { + client.putObject(config, (err, data) => { + console.log('腾讯上传', err, data); + if (err) { + reject(err); + } else { + resolve(data.Location); + } + }); + }); +} diff --git a/src/views/Design/components/Questions/Choice.vue b/src/views/Design/components/Questions/Choice.vue index f9e0ddb..6257010 100644 --- a/src/views/Design/components/Questions/Choice.vue +++ b/src/views/Design/components/Questions/Choice.vue @@ -57,9 +57,11 @@ + diff --git a/src/views/Design/components/Questions/SignQuestion.vue b/src/views/Design/components/Questions/SignQuestion.vue index 06bc5b2..fe923a0 100644 --- a/src/views/Design/components/Questions/SignQuestion.vue +++ b/src/views/Design/components/Questions/SignQuestion.vue @@ -13,7 +13,6 @@ const signatureCanvas = useTemplateRef('signatureCanvas'); const canvasWidth = ref(100); const canvasHeight = computed(() => canvasWidth.value / 1.5); -const showSignText = ref(true); const isEraser = ref(false); let ctx: CanvasRenderingContext2D; @@ -193,7 +192,7 @@ const emitValue = () => { style="border: 1px dashed #ccc; border-radius: 4px" > -
+
{ >
-
请在空白区域书写您的签名
+
请在空白区域书写您的签名
@@ -259,13 +258,14 @@ const emitValue = () => { } } } + .sign-tips { position: absolute; - left: 50%; top: 50%; + left: 50%; width: max-content; - transform: translate(-50%, -50%); color: #cdcdcd; + transform: translate(-50%, -50%); } } diff --git a/src/views/Survey/views/Create/Index.vue b/src/views/Survey/views/Create/Index.vue index 468ec17..97e1616 100644 --- a/src/views/Survey/views/Create/Index.vue +++ b/src/views/Survey/views/Create/Index.vue @@ -97,6 +97,10 @@
+ + + +
保存 预览 @@ -397,14 +401,14 @@ const questionEvent = (item) => { options: item.json.options.length > 0 ? item.json.options.map((item) => { - return item.map((it) => { - return { - ...it, - // 主键生成 - id: uuidv4() - }; - }); - }) + return item.map((it) => { + return { + ...it, + // 主键生成 + id: uuidv4() + }; + }); + }) : [] }) ); @@ -537,7 +541,7 @@ const previewQuestion = () => { router.push({ name: 'preview', query: { ...route.query } }); }; -onMounted(async () => { +onMounted(async() => { await getQuestionDetail(); }); diff --git a/src/views/Survey/views/Publish/Index.vue b/src/views/Survey/views/Publish/Index.vue index 04661b8..bf76b21 100644 --- a/src/views/Survey/views/Publish/Index.vue +++ b/src/views/Survey/views/Publish/Index.vue @@ -4,9 +4,11 @@
- + alt="" + />
@@ -26,8 +28,13 @@
点击"启用"按钮后,问卷才可以开始回收数据
- + @@ -92,21 +99,21 @@ type OperateItem = (typeof operateList)[0]; const operateBtn = (item: OperateItem) => { switch (item.type) { - case 'shareLink': - shareLink(); - break; - case 'copyLink': - copyLink(); - break; - case 'qrCode': - downLoadImg(); - break; - default: - break; + case 'shareLink': + shareLink(); + break; + case 'copyLink': + copyLink(); + break; + case 'qrCode': + downLoadImg(); + break; + default: + break; } }; // 复制链接 -function copyLink () { +function copyLink() { const input = document.createElement('input'); input.value = publishInfo.value.url; document.body.appendChild(input); @@ -116,7 +123,7 @@ function copyLink () { showToast('复制成功'); } // 分享链接 -function shareLink () { +function shareLink() { const params = { type: 'shareToWx', title: publishInfo.value.download_url.title, @@ -126,11 +133,11 @@ function shareLink () { scene: 0 // 朋友圈1 微信好友0 }; console.log('shareUrl', publishInfo.value.url); - appBridge.shareToWeChat(params, () => { }); + appBridge.shareToWeChat(params); } // 下载二维码 -function downLoadImg () { +function downLoadImg() { const { title, url } = publishInfo.value.download_url; if (utils.getSessionStorage('xToken')) { appBridge.save2Album(url, () => { @@ -145,7 +152,7 @@ function downLoadImg () { document.body.removeChild(link); } } -async function openPublishModal () { +async function openPublishModal() { const res = await canPlanetPublish(route.query.sn as string, publishType.value); if (res) { await publishSurvey({ @@ -161,7 +168,7 @@ async function openPublishModal () { } } -function getCode () { +function getCode() { getQrcode(sn) .then((res) => { if (res.data) { @@ -172,7 +179,7 @@ function getCode () { showFailToast(error.data?.message || error.message || '服务器错误'); }); } -function fetchInfo () { +function fetchInfo() { getSurveyInfo(sn) .then((res) => { status.value = Number(res.data.data.status); @@ -186,7 +193,7 @@ watch(status, (val) => { getCode(); } }); -onMounted(async () => { +onMounted(async() => { // status.value = 0; // publishInfo.value.img_url // = 'https://test-cxp-pubcos.yili.com/uat-yls//survey-api/publish/202503130938138261340.png';