From 6af46031717f8750707b709fc6fa16cad5d309cd Mon Sep 17 00:00:00 2001 From: wanganmao <525987762@qq.com> Date: Thu, 20 Oct 2022 14:52:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=97=AE=E5=8D=B7=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Layouts/BaseLayout.vue | 93 ++++++++++--------- src/Layouts/utils.js | 62 +++++++++++++ .../launch-center/launch-task/index.vue | 38 ++++---- src/views/Publish/link.vue | 10 +- 4 files changed, 143 insertions(+), 60 deletions(-) create mode 100644 src/Layouts/utils.js diff --git a/src/Layouts/BaseLayout.vue b/src/Layouts/BaseLayout.vue index 5503cee2..4dc9307f 100644 --- a/src/Layouts/BaseLayout.vue +++ b/src/Layouts/BaseLayout.vue @@ -126,7 +126,8 @@ import Avatar from "@/views/Home/components/Avatar.vue"; import { tr } from "element-plus/lib/locale"; import { Modal } from "ant-design-vue"; import { cloneDeep } from "lodash"; -import DownloadCenter from "@/views/DownloadCenter/index.vue" +import DownloadCenter from "@/views/DownloadCenter/index.vue"; +import { canPlanetPublish } from "./utils"; const router = useRouter(); const route = useRoute(); @@ -229,50 +230,58 @@ const toPreview = () => { document.title = name; }; -const openPublishModal = () => { - //console.log(); - // return; - let isFb = true; - let content = ""; - const qSteams = []; - let type = 0; - let title = "推荐提示"; - store.state.common.questionInfo.questions && - store.state.common.questionInfo.questions.forEach((s) => { - if (s.question_type === 105 && s.config.design_version <= 0) { - isFb = false; - content = createVNode(
maxdiff未生成设计,请先进行生成设计才能进行发布
); - title = "推荐提示"; - type = 1; - } - if (s.question_type === 25 || s.question_type === 26) { - if ((s.options?.[0]?.length || 0) <= 0 && (s?.associate?.length || 0) <= 0) { - isFb = false; - qSteams.push(`(${s.title})`); - type = 2; - } - } - }); +const openPublishModal = async () => { - if (isFb === true) { + var res = await canPlanetPublish(route.query.sn); + + if(res){ visible.value = true; - } else { - if (type === 2) { - const titleStr = qSteams.join(","); - title = "添加选区"; - content = createVNode(
{titleStr} 未添加选区,请添加选区后进行发布
); - } - Modal.confirm({ - title: title, - icon: createVNode(ExclamationCircleOutlined), - content: content, - onOk () { }, - width: "640px", - height: "364px", - onCancel () { }, - class: "test", - }); + return; } + + // //console.log(); + // // return; + // let isFb = true; + // let content = ""; + // const qSteams = []; + // let type = 0; + // let title = "推荐提示"; + // store.state.common.questionInfo.questions && + // store.state.common.questionInfo.questions.forEach((s) => { + // if (s.question_type === 105 && s.config.design_version <= 0) { + // isFb = false; + // content = createVNode(
maxdiff未生成设计,请先进行生成设计才能进行发布
); + // title = "推荐提示"; + // type = 1; + // } + // if (s.question_type === 25 || s.question_type === 26) { + // if ((s.options?.[0]?.length || 0) <= 0 && (s?.associate?.length || 0) <= 0) { + // isFb = false; + // qSteams.push(`(${s.title})`); + // type = 2; + // } + // } + // }); + + // if (isFb === true) { + // visible.value = true; + // } else { + // if (type === 2) { + // const titleStr = qSteams.join(","); + // title = "添加选区"; + // content = createVNode(
{titleStr} 未添加选区,请添加选区后进行发布
); + // } + // Modal.confirm({ + // title: title, + // icon: createVNode(ExclamationCircleOutlined), + // content: content, + // onOk () { }, + // width: "640px", + // height: "364px", + // onCancel () { }, + // class: "test", + // }); + // } }; const handlePublish = () => { diff --git a/src/Layouts/utils.js b/src/Layouts/utils.js new file mode 100644 index 00000000..4abde5cd --- /dev/null +++ b/src/Layouts/utils.js @@ -0,0 +1,62 @@ + +import { createVNode } from "vue"; +import { Modal } from "ant-design-vue"; +import { getQuestionList } from "@/views/planetDesign/api/api.js"; +import { ExclamationCircleOutlined } from "@ant-design/icons-vue"; + +/** + * 判断问卷是否可以发布(原本应该后端实现,前端实现会有并发的问题,但后端表示做不了) + */ +export const canPlanetPublish = async function(sn) { + + let num = window.location.href.indexOf("code="); + let code; + if (num > -1) { + code = window.location.href.slice(num + 5, window.location.href.length); + } else { + code = ""; + } + const { data } = await getQuestionList(sn, code); + + let isFb = true; + let content = ""; + const qSteams = []; + let type = 0; + let title = "推荐提示"; + data.questions && + data.questions.forEach((s) => { + if (s.question_type === 105 && s.config.design_version <= 0) { + isFb = false; + content = createVNode(
maxdiff未生成设计,请先进行生成设计才能进行发布
); + title = "推荐提示"; + type = 1; + } + if (s.question_type === 25 || s.question_type === 26) { + if ((s.options?.[0]?.length || 0) <= 0 && (s?.associate?.length || 0) <= 0) { + isFb = false; + qSteams.push(`(${s.title})`); + type = 2; + } + } + }); + + if (isFb === true) { + visible.value = true; + } else { + if (type === 2) { + const titleStr = qSteams.join(","); + title = "添加选区"; + content = createVNode(
{titleStr} 未添加选区,请添加选区后进行发布
); + } + Modal.confirm({ + title: title, + icon: createVNode(ExclamationCircleOutlined), + content: content, + onOk () { }, + width: "640px", + height: "364px", + onCancel () { }, + class: "test", + }); + } +} \ No newline at end of file diff --git a/src/views/Publish/launch-center/launch-task/index.vue b/src/views/Publish/launch-center/launch-task/index.vue index fbecd3ef..79a1765e 100644 --- a/src/views/Publish/launch-center/launch-task/index.vue +++ b/src/views/Publish/launch-center/launch-task/index.vue @@ -82,6 +82,8 @@ import { deliveryPlans } from "../api/php"; import { Modal } from "ant-design-vue"; import Pagination, { getPagination } from "@components/Pagination.vue"; // import { getAnswerSetting } from "@/views/planetDesign/api/api"; +import { canPlanetPublish } from "@/Layouts/utils.js"; + export default { components: { shareLinks, @@ -170,22 +172,26 @@ export default { pagination.value.pageSize = data?.meta?.per_page; }; - const openPublishModal = () => { - Modal.confirm({ - title: "提示", - // icon: createVNode(ExclamationCircleOutlined), - content: "确定发布该问卷?", - okText: "确认", - cancelText: "取消", - onOk: async () => { - await publishSurvey({ - publish_type: 0, - sn: route.query.sn, - }); - status.value = 1; - getList(status); - }, - }); + const openPublishModal = async () => { + var res = await canPlanetPublish(route.query.sn); + if(res){ + Modal.confirm({ + title: "提示", + // icon: createVNode(ExclamationCircleOutlined), + content: "确定发布该问卷?", + okText: "确认", + cancelText: "取消", + onOk: async () => { + await publishSurvey({ + publish_type: 0, + sn: route.query.sn, + }); + status.value = 1; + getList(status); + }, + }); + return; + } }; onMounted(async () => { diff --git a/src/views/Publish/link.vue b/src/views/Publish/link.vue index aca1f080..11ef9a50 100644 --- a/src/views/Publish/link.vue +++ b/src/views/Publish/link.vue @@ -240,6 +240,8 @@ import launchListEmpty from "./launch-center/components/launchListEmpty"; import { DownOutlined, ExclamationCircleOutlined } from "@ant-design/icons-vue"; import { Modal } from "ant-design-vue"; import SubTitle from "../DataAnalyse/components/SubTitle.vue"; +import { canPlanetPublish } from "@/Layouts/utils.js"; + const route = useRoute(); const sn = route.query.sn; @@ -566,8 +568,12 @@ function handleAddSOk() { }); } -function openPublishModal() { - visible.value = true; +async function openPublishModal() { + var res = await canPlanetPublish(route.query.sn); + if(res){ + visible.value = true; + return; + } } function handlePublish() { publishSurvey({