fix: 问卷发布验证
This commit is contained in:
@@ -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(<div>maxdiff未生成设计,请先进行生成设计才能进行发布</div>);
|
||||
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(<div>{titleStr} 未添加选区,请添加选区后进行发布</div>);
|
||||
}
|
||||
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(<div>maxdiff未生成设计,请先进行生成设计才能进行发布</div>);
|
||||
// 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(<div>{titleStr} 未添加选区,请添加选区后进行发布</div>);
|
||||
// }
|
||||
// Modal.confirm({
|
||||
// title: title,
|
||||
// icon: createVNode(ExclamationCircleOutlined),
|
||||
// content: content,
|
||||
// onOk () { },
|
||||
// width: "640px",
|
||||
// height: "364px",
|
||||
// onCancel () { },
|
||||
// class: "test",
|
||||
// });
|
||||
// }
|
||||
};
|
||||
|
||||
const handlePublish = () => {
|
||||
|
||||
62
src/Layouts/utils.js
Normal file
62
src/Layouts/utils.js
Normal file
@@ -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(<div>maxdiff未生成设计,请先进行生成设计才能进行发布</div>);
|
||||
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(<div>{titleStr} 未添加选区,请添加选区后进行发布</div>);
|
||||
}
|
||||
Modal.confirm({
|
||||
title: title,
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
content: content,
|
||||
onOk () { },
|
||||
width: "640px",
|
||||
height: "364px",
|
||||
onCancel () { },
|
||||
class: "test",
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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,7 +172,9 @@ export default {
|
||||
pagination.value.pageSize = data?.meta?.per_page;
|
||||
};
|
||||
|
||||
const openPublishModal = () => {
|
||||
const openPublishModal = async () => {
|
||||
var res = await canPlanetPublish(route.query.sn);
|
||||
if(res){
|
||||
Modal.confirm({
|
||||
title: "提示",
|
||||
// icon: createVNode(ExclamationCircleOutlined),
|
||||
@@ -186,6 +190,8 @@ export default {
|
||||
getList(status);
|
||||
},
|
||||
});
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -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() {
|
||||
async function openPublishModal() {
|
||||
var res = await canPlanetPublish(route.query.sn);
|
||||
if(res){
|
||||
visible.value = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
function handlePublish() {
|
||||
publishSurvey({
|
||||
|
||||
Reference in New Issue
Block a user