diff --git a/.vscode/settings.json b/.vscode/settings.json index a4f3d56..d7d9cd8 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,77 +1,77 @@ -{ - "explorer.confirmDelete": false, - "editor.fontSize": 16, - "workbench.editorAssociations": { - "*.ipynb": "jupyter.notebook.ipynb" - }, - "window.zoomLevel": 1, - "workbench.iconTheme": "vscode-icons", - "prettier.enable": true, - "editor.formatOnSave": false, - "javascript.format.insertSpaceBeforeFunctionParenthesis": true, - "typescript.format.insertSpaceBeforeFunctionParenthesis": true, - "prettier.singleQuote": true, - "emmet.syntaxProfiles": { - "vue-html": "html", - "vue": "html" - }, - "files.associations": { - "*.html": "html", - "*.vue": "vue", - "*.ejs": "html", - "*.js": "javascript" - }, - "vsicons.dontShowNewVersionMessage": true, - "autoimport.showNotifications": true, - "path-intellisense.mappings": { - "@": "${workspaceRoot}/src", - "/": "${workspaceRoot}/" - }, - "[html]": { - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.formatOnSave": true - }, - "[vue]": { - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.formatOnSave": true - }, - "css.validate": false, //用来校验CSS文件中的语法错误和潜在的问题 - "less.validate": false, //用来校验LESS文件中的语法错误和潜在的问题 - "scss.validate": false, //用来校验SCSS文件中的语法错误和潜在的问题 - "editor.codeActionsOnSave": { - // 用于在保存文件时自动执行代码操作 - "source.fixAll.eslint": "explicit", // 自动执行ESlint - "source.fixAll.stylelint": "explicit" // 自动执行stylelint - }, - "eslint.validate": [ - "javascript", - "javascriptreact", - "typescript", - "typescriptreact", - "html", - "markdown", - "yaml", - "toml", - "xml", - "gql", - "graphql", - "astro" - ], - "eslint.nodePath": "./node_modules/@yl/yili-fe-lint-config/node_modules", // 指定ESLint可执行文件路径 - "eslint.options": { - // 用于配置 - "overrideConfigFile": "./node_modules/@yl/yili-fe-lint-config/eslintrc.vue3.js" //该选项指定了 ESLint 应使用的配置文件路径。此项设置会覆盖所有其他位置查找的 ESLint 配置文件。 - }, - "stylelint.configBasedir": "./node_modules/@yl/yili-fe-lint-config/", //该选项用于定义 Stylelint 配置文件所基于的基础目录。当您的配置文件中使用 extends、plugins 或其他引用时,这个基础目录将作为解析路径的起点 - "stylelint.configFile": "./node_modules/@yl/yili-fe-lint-config/stylelintrc.js", // 该选项指定了 stylelint 应使用的配置文件路径。此项设置会覆盖所有其他位置查找的 stylelint 配置文件 - "stylelint.customSyntax": "postcss-scss", // 配置stylelint使用的预处理器 - "stylelint.stylelintPath": "./node_modules/@yl/yili-fe-lint-config/node_modules/stylelint", // 指定stylelint安装路径 - "stylelint.validate": [ - "html", - "css", - "scss", - "less", - "vue" - ], - "typescript.tsdk": "node_modules\\typescript\\lib" -} +{ + "explorer.confirmDelete": false, + "editor.fontSize": 16, + "workbench.editorAssociations": { + "*.ipynb": "jupyter.notebook.ipynb" + }, + "window.zoomLevel": 1, + "workbench.iconTheme": "material-icon-theme", + "prettier.enable": true, + "editor.formatOnSave": false, + "javascript.format.insertSpaceBeforeFunctionParenthesis": true, + "typescript.format.insertSpaceBeforeFunctionParenthesis": true, + "prettier.singleQuote": true, + "emmet.syntaxProfiles": { + "vue-html": "html", + "vue": "html" + }, + "files.associations": { + "*.html": "html", + "*.vue": "vue", + "*.ejs": "html", + "*.js": "javascript" + }, + "vsicons.dontShowNewVersionMessage": true, + "autoimport.showNotifications": true, + "path-intellisense.mappings": { + "@": "${workspaceRoot}/src", + "/": "${workspaceRoot}/" + }, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "[vue]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + "editor.formatOnSave": true + }, + "css.validate": false, //用来校验CSS文件中的语法错误和潜在的问题 + "less.validate": false, //用来校验LESS文件中的语法错误和潜在的问题 + "scss.validate": false, //用来校验SCSS文件中的语法错误和潜在的问题 + "editor.codeActionsOnSave": { + // 用于在保存文件时自动执行代码操作 + "source.fixAll.eslint": "explicit", // 自动执行ESlint + "source.fixAll.stylelint": "explicit" // 自动执行stylelint + }, + "eslint.validate": [ + "javascript", + "javascriptreact", + "typescript", + "typescriptreact", + "html", + "markdown", + "yaml", + "toml", + "xml", + "gql", + "graphql", + "astro" + ], + "eslint.nodePath": "./node_modules/@yl/yili-fe-lint-config/node_modules", // 指定ESLint可执行文件路径 + "eslint.options": { + // 用于配置 + "overrideConfigFile": "./node_modules/@yl/yili-fe-lint-config/eslintrc.vue3.js" //该选项指定了 ESLint 应使用的配置文件路径。此项设置会覆盖所有其他位置查找的 ESLint 配置文件。 + }, + "stylelint.configBasedir": "./node_modules/@yl/yili-fe-lint-config/", //该选项用于定义 Stylelint 配置文件所基于的基础目录。当您的配置文件中使用 extends、plugins 或其他引用时,这个基础目录将作为解析路径的起点 + "stylelint.configFile": "./node_modules/@yl/yili-fe-lint-config/stylelintrc.js", // 该选项指定了 stylelint 应使用的配置文件路径。此项设置会覆盖所有其他位置查找的 stylelint 配置文件 + "stylelint.customSyntax": "postcss-scss", // 配置stylelint使用的预处理器 + "stylelint.stylelintPath": "./node_modules/@yl/yili-fe-lint-config/node_modules/stylelint", // 指定stylelint安装路径 + "stylelint.validate": [ + "html", + "css", + "scss", + "less", + "vue" + ], + "typescript.tsdk": "node_modules\\typescript\\lib" +} diff --git a/src/components/Analysis/Index.vue b/src/components/Analysis/Index.vue index 6a175f8..b59f075 100644 --- a/src/components/Analysis/Index.vue +++ b/src/components/Analysis/Index.vue @@ -1,9 +1,6 @@ - - - - + + + + + diff --git a/src/views/Survey/hooks/useSurveyData.ts b/src/views/Survey/hooks/useSurveyData.ts index 4fc62b2..d24b0eb 100644 --- a/src/views/Survey/hooks/useSurveyData.ts +++ b/src/views/Survey/hooks/useSurveyData.ts @@ -1,117 +1,109 @@ -import { - getSurveysPage, deleteSurveys, - saveTemplates -} from '@/api/home'; -import { ref } from 'vue'; -import { - showDialog, - showConfirmDialog, - showFailToast, - showToast -} from 'vant'; -import { getSurveysDetail } from '@/api/design'; - -const form = ref({ - page: 0, - pageSize: 10, - project_name: '' -}); - -const searchValue = ref(''); -const survey = ref([]); -const total = ref(0); -const loading = ref(false); -const finished = ref(false); -const currentSurvey = ref(); - -async function fetchSingleSurvey(sn: string) { - const res = await getSurveysDetail(sn); - // console.log(res); - if (res.data.code === 0) { - currentSurvey.value = res.data.data; - } -} - -async function fetchSurveys() { - const params = { - page: form.value.page, - per_page: form.value.pageSize, - group_id: 0, - project_name: searchValue.value - }; - const res = await getSurveysPage(params); - if (res.data.code === 0) { - survey.value = survey.value.concat(res.data.data); - total.value = res.data.meta.total; - survey.value.forEach((item) => { - const sceneName = JSON.parse(JSON.stringify(item.scene_name)); - const nameList = sceneName.split('-'); - if (nameList.length > 0) { - item.scene_name = nameList[1] ? nameList[1] : nameList[0]; - } - - const timeList = item.created_at.split(' '); - if (nameList.length) { - item.created_at = timeList[0]; - } - }); - loading.value = false; - // 数据全部加载完成 - if (survey.value.length >= total.value) { - finished.value = true; - } - } else { - // Toast() - } -} - -function deleteItem(item: SurveyItem) { - showDialog({ - title: `确认删除问卷${item.project_name} ?`, - showCancelButton: true, - confirmButtonColor: '#03B03C' - }) - .then(async () => { - const res = await deleteSurveys(item.sn); - if (res.data.message) { - showToast(res.data.message); - } else { - showToast('删除成功!'); - } - form.value.page = 1; - survey.value = []; - await fetchSurveys(); - }) - .catch(() => { - // on cancel - }); -}; - -// 保存为模板 -async function saveTemplate(item: SurveyItem) { - const data = JSON.parse(JSON.stringify(item)); - const res = await saveTemplates(item.sn, data); - if (res.data.code === 200 || res.data.code === 201) { - showConfirmDialog({ - message: '模板保存成功,请前往模板市场查看!', - showCancelButton: false - }); - } else { - showFailToast(res.data); - } -} - -export { - form, - fetchSurveys, - loading, - finished, - survey, - total, - searchValue, - deleteItem, - saveTemplate, - currentSurvey, - fetchSingleSurvey -} - ; \ No newline at end of file +import { getSurveysPage, deleteSurveys, saveTemplates } from '@/api/home'; +import { ref } from 'vue'; +import { showDialog, showConfirmDialog, showFailToast, showToast } from 'vant'; +import { getSurveysDetail } from '@/api/design'; + +const form = ref({ + page: 0, + pageSize: 10, + project_name: '' +}); + +const searchValue = ref(''); +const survey = ref([]); +const total = ref(0); +const loading = ref(false); +const finished = ref(false); +const currentSurvey = ref(); + +async function fetchSingleSurvey(sn: string) { + const res = await getSurveysDetail(sn); + // console.log(res); + if (res.data.code === 0) { + currentSurvey.value = res.data.data; + } +} + +async function fetchSurveys() { + const params = { + page: form.value.page, + per_page: form.value.pageSize, + group_id: 0, + project_name: searchValue.value + }; + const res = await getSurveysPage(params); + if (res.data.code === 0) { + survey.value = survey.value.concat(res.data.data); + total.value = res.data.meta.total; + survey.value.forEach((item) => { + const sceneName = JSON.parse(JSON.stringify(item.scene_name)); + + const nameList = sceneName ? sceneName.split('-') : []; + if (nameList.length > 0) { + item.scene_name = nameList[1] ? nameList[1] : nameList[0]; + } + + const timeList = item.created_at.split(' '); + if (nameList.length) { + item.created_at = timeList[0]; + } + }); + loading.value = false; + // 数据全部加载完成 + if (survey.value.length >= total.value) { + finished.value = true; + } + } else { + // Toast() + } +} + +function deleteItem(item: SurveyItem) { + showDialog({ + title: `确认删除问卷${item.project_name} ?`, + showCancelButton: true, + confirmButtonColor: '#03B03C' + }) + .then(async () => { + const res = await deleteSurveys(item.sn); + if (res.data.message) { + showToast(res.data.message); + } else { + showToast('删除成功!'); + } + form.value.page = 1; + survey.value = []; + await fetchSurveys(); + }) + .catch(() => { + // on cancel + }); +} + +// 保存为模板 +async function saveTemplate(item: SurveyItem) { + const data = JSON.parse(JSON.stringify(item)); + const res = await saveTemplates(item.sn, data); + if (res.data.code === 200 || res.data.code === 201) { + showConfirmDialog({ + message: '模板保存成功,请前往模板市场查看!', + showCancelButton: false + }); + } else { + showFailToast(res.data); + } +} + +export { + form, + fetchSurveys, + loading, + finished, + survey, + total, + searchValue, + deleteItem, + saveTemplate, + currentSurvey, + fetchSingleSurvey +}; diff --git a/src/views/Survey/views/Analysis/Index.vue b/src/views/Survey/views/Analysis/Index.vue index 6fafaf3..caba67b 100644 --- a/src/views/Survey/views/Analysis/Index.vue +++ b/src/views/Survey/views/Analysis/Index.vue @@ -17,6 +17,8 @@ const route = useRoute(); * 如果当前问卷的数据不存在,重新获取数据 */ if (!currentSurvey.value) fetchSingleSurvey(route.query.sn as string); +// 重置 message 信息 +aiInsightsConfig.value.message = ''; useFetchAnalysis(route.query.sn as string); @@ -45,7 +47,7 @@ useFetchAnalysis(route.query.sn as string); - +