diff --git a/src/Layouts/BaseLayout.vue b/src/Layouts/BaseLayout.vue index 049652f8..c1b24df5 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..c88fcfa6 --- /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) { + return 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/Answer/components/PreviewLayout.vue b/src/views/Answer/components/PreviewLayout.vue index 62e284fe..9ca74b59 100644 --- a/src/views/Answer/components/PreviewLayout.vue +++ b/src/views/Answer/components/PreviewLayout.vue @@ -133,6 +133,7 @@ import useCopy from "@/composables/useCopy"; // eslint-disable-next-line vue/no-unused-components import { message } from "ant-design-vue"; +import { canPlanetPublish } from "@/Layouts/utils.js"; export default defineComponent({ components: { Phone, QuestionsPc, QuestionsMob, SurveyDownload, QuestionDetail, RemarkDrawer }, @@ -200,6 +201,10 @@ export default defineComponent({ } // 发布 async function issue() { + + var res = await canPlanetPublish(proxy.$route.query.sn); + if(!res) return; + issueLoading.value = true; try { await publishSurvey({ diff --git a/src/views/Answer/questions/QMatrix/components/MRate.vue b/src/views/Answer/questions/QMatrix/components/MRate.vue index f0136da3..611f9c59 100644 --- a/src/views/Answer/questions/QMatrix/components/MRate.vue +++ b/src/views/Answer/questions/QMatrix/components/MRate.vue @@ -34,9 +34,9 @@ diff --git a/src/views/Answer/questions/QRate.vue b/src/views/Answer/questions/QRate.vue index c11391fa..773cee37 100644 --- a/src/views/Answer/questions/QRate.vue +++ b/src/views/Answer/questions/QRate.vue @@ -21,22 +21,10 @@ :disabled="disabled" > props.answer, () => { - if (options.value.length > 1) - context.emit("changeAnswer", { options: options.value }); + if (options.value.length > 1) context.emit("changeAnswer", { options: options.value }); }, { deep: true, @@ -200,8 +187,7 @@ export default defineComponent({ }); if (props.answer) { newOptions.forEach((newOption) => { - if (!newOption.value) - newOption.value = props.answer[newOption.option_key]; + if (!newOption.value) newOption.value = props.answer[newOption.option_key]; }); } else { newOptions.forEach((newOption) => { 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({ diff --git a/src/views/planetDesign/Design/questions/choice/ChoiceConfig.vue b/src/views/planetDesign/Design/questions/choice/ChoiceConfig.vue index 12f21c4b..f199ac30 100644 --- a/src/views/planetDesign/Design/questions/choice/ChoiceConfig.vue +++ b/src/views/planetDesign/Design/questions/choice/ChoiceConfig.vue @@ -170,7 +170,7 @@ export default { updateConfig(copyConfig.value); }; const inputNumChange = (e) => { - copyConfig.value.config.each_number = Number(e).toFixed(0); + copyConfig.value.config.each_number = (Number(e) || 1).toFixed(0); }; const updateConfig = (newConfig) => { context.emit("update", newConfig); diff --git a/src/views/schedule/recycle.vue b/src/views/schedule/recycle.vue index a30ac517..8855af69 100644 --- a/src/views/schedule/recycle.vue +++ b/src/views/schedule/recycle.vue @@ -13,7 +13,7 @@ />
-
今日回收量
+
今日回收量
{{ from.num1 }}
@@ -29,7 +29,7 @@ />
-
完成回收总量
+
完成回收总量
{{ from.num2 }}
@@ -45,7 +45,7 @@ />
-
发布数量
+
发布数量
{{ from.num3 }}