This commit is contained in:
王博冉
2022-10-24 15:44:22 +08:00
10 changed files with 171 additions and 97 deletions

View File

@@ -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
View 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) {
return 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",
});
}
}

View File

@@ -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({

View File

@@ -34,9 +34,9 @@
<slider-num-rate
rateType="num"
:param="{
interval: config.score_interval,
max: config.max,
min: config.min,
interval: config.score_interval * 1,
max: config.max * 1,
min: config.min * 1,
}"
:value="value"
:disabled="disabled"
@@ -49,9 +49,9 @@
<slider-num-rate
rateType="slider"
:param="{
interval: config.score_interval*1,
max: config.max*1,
min: config.min*1,
interval: config.score_interval * 1,
max: config.max * 1,
min: config.min * 1,
}"
:value="value"
:disabled="disabled"

View File

@@ -5,7 +5,7 @@
class="radio"
v-for="option in options"
:key="option.option_key"
:style="isMobile ? 'width: 100%' : `width: calc(100% / ${config.each_number} - 32px)`"
:style="isMobile ? 'width: 100%' : `width: calc(100% / ${(config.each_number || 1)} - 33px)`"
v-show="!hideOptions.includes(option.option_key)"
>
<a-radio :value="option.option_key" />

View File

@@ -21,22 +21,10 @@
:disabled="disabled"
>
<template #character>
<span
v-if="config.score_type === 0"
class="icon iconfont icon-star-fill"
/>
<span
v-else-if="config.score_type === 2"
class="icon iconfont icon-heart-fill"
/>
<span
v-else-if="config.score_type === 3"
class="icon iconfont icon-smile-fill"
/>
<span
v-else-if="config.score_type === 4"
class="icon iconfont icon-thumb-fill"
/>
<span v-if="config.score_type === 0" class="icon iconfont icon-star-fill" />
<span v-else-if="config.score_type === 2" class="icon iconfont icon-heart-fill" />
<span v-else-if="config.score_type === 3" class="icon iconfont icon-smile-fill" />
<span v-else-if="config.score_type === 4" class="icon iconfont icon-thumb-fill" />
</template>
</a-rate>
<rich-rate-item
@@ -54,9 +42,9 @@
<slider-num-rate
rateType="num"
:param="{
interval: config.score_interval,
max: config.max,
min: config.min,
interval: config.score_interval * 1,
max: config.max * 1,
min: config.min * 1,
}"
v-model:value="option.value"
@update:value="updateAnswer"
@@ -68,9 +56,9 @@
<slider-num-rate
rateType="slider"
:param="{
interval: config.score_interval,
max: config.max,
min: config.min,
interval: config.score_interval * 1,
max: config.max * 1,
min: config.min * 1,
}"
v-model:value="option.value"
@update:value="updateAnswer"
@@ -180,8 +168,7 @@ export default defineComponent({
watch(
() => 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) => {

View File

@@ -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 () => {

View File

@@ -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({

View File

@@ -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);

View File

@@ -13,7 +13,7 @@
/>
</div>
<div class="title">
<div style="color: #5E5E5E;">今日回收量</div>
<div style="color: #5E5E5E;width:100px">今日回收量</div>
<div style="margin-top: 19px; font-weight: 800; font-size: 28px">
{{ from.num1 }}
</div>
@@ -29,7 +29,7 @@
/>
</div>
<div class="title">
<div style="color: #5E5E5E;">完成回收总量</div>
<div style="color: #5E5E5E;;width:100px">完成回收总量</div>
<div style="margin-top: 19px; font-weight: 800; font-size: 28px">
{{ from.num2 }}
</div>
@@ -45,7 +45,7 @@
/>
</div>
<div class="title">
<div>发布数量</div>
<div style="width:100px">发布数量</div>
<div style="margin-top: 15px; font-weight: 800; font-size: 28px">
{{ from.num3 }}
</div>