feat(survey): 添加取消投放功能
- 在 survey/index.js 中新增 modify 函数,用于修改投放状态 - 在 Survey/Index.vue 中添加取消投放逻辑 - 优化 Publish/Index.vue 的样式
This commit is contained in:
@@ -43,3 +43,14 @@ export function getQuestionList(params, code) {
|
||||
method: 'get'
|
||||
});
|
||||
}
|
||||
|
||||
/*取消投放*/
|
||||
export function modify(params, code) {
|
||||
return request({
|
||||
headers: {
|
||||
'survey-invite-code': code || ''
|
||||
},
|
||||
url: `/console/question/publish/modify`,
|
||||
method: 'POST'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ const functions = {
|
||||
document.execCommand('italic', false, null);
|
||||
},
|
||||
|
||||
uploadImage: async () => {
|
||||
uploadImage: async() => {
|
||||
// 保存当前光标位置
|
||||
savedRange.value = saveSelection();
|
||||
|
||||
@@ -84,7 +84,7 @@ const functions = {
|
||||
|
||||
fileInput.click();
|
||||
|
||||
fileInput.onchange = async (e) => {
|
||||
fileInput.onchange = async(e) => {
|
||||
const [file] = e.target.files;
|
||||
if (!file) return;
|
||||
if (file.size > 2 * 1024 * 1024) {
|
||||
@@ -146,10 +146,10 @@ const isEmptyContent = (html) => {
|
||||
const trimmedHtml = html.trim();
|
||||
// 检查是否为空字符串、仅包含 <br> 或仅包含 <p><br></p>
|
||||
return (
|
||||
trimmedHtml === '' ||
|
||||
trimmedHtml === '<br>' ||
|
||||
trimmedHtml === '<p><br></p>' ||
|
||||
trimmedHtml === '<p></p>'
|
||||
trimmedHtml === ''
|
||||
|| trimmedHtml === '<br>'
|
||||
|| trimmedHtml === '<p><br></p>'
|
||||
|| trimmedHtml === '<p></p>'
|
||||
);
|
||||
};
|
||||
|
||||
@@ -157,7 +157,7 @@ const onChange = (target) => {
|
||||
console.log(target.innerHTML.trim(), 123);
|
||||
if (isEmptyContent(target.innerHTML)) {
|
||||
editor.value.classList.add('editor-placeholder');
|
||||
//删除br
|
||||
// 删除br
|
||||
editor.value.innerHTML = editor.value.innerHTML.replace(/<br>/g, '');
|
||||
} else {
|
||||
editor.value.classList.remove('editor-placeholder');
|
||||
|
||||
@@ -39,7 +39,7 @@ export default {
|
||||
prompt_right: '',
|
||||
score_interval: 1,
|
||||
score_type: 0,
|
||||
score_way: 0,
|
||||
score_way: 1, //打分类型
|
||||
prompt_score: 2
|
||||
},
|
||||
associate: [],
|
||||
|
||||
@@ -105,7 +105,7 @@ function handleMatrixCheckboxChange(row: number, col: number) {
|
||||
// emits('update:matrixAnswer', props.matrixAnswer);
|
||||
// emits('update:rowRecord', props.rowRecord);
|
||||
// };
|
||||
const emitValue = (/*val: unknown*/) => {
|
||||
const emitValue = (/* val: unknown */) => {
|
||||
emit('update:element', element.value);
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -74,7 +74,9 @@
|
||||
<el-text style="color: #71b73c">预览</el-text>
|
||||
</el-button>
|
||||
<el-button color="#6fb937" :disabled="item.source === 0" @click="toPublish(item)">
|
||||
<el-text style="color: white">开启投放</el-text>
|
||||
<el-text style="color: white">{{
|
||||
item.status === 1 ? '取消投放' : '开启投放'
|
||||
}}</el-text>
|
||||
</el-button>
|
||||
</div>
|
||||
<el-dropdown
|
||||
@@ -106,6 +108,7 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { getSurveysPage, copySurveys, deleteSurveys, saveTemplates } from '@/api/home/index.js';
|
||||
import { modify } from '@/api/survey/index.js';
|
||||
import { showDialog, showConfirmDialog, showFailToast, showSuccessToast, showToast } from 'vant';
|
||||
import { useRouter } from 'vue-router';
|
||||
const router = useRouter();
|
||||
@@ -134,7 +137,7 @@ const onLoad = () => {
|
||||
fetchSurveys();
|
||||
}, 500);
|
||||
};
|
||||
const fetchSurveys = async() => {
|
||||
const fetchSurveys = async () => {
|
||||
const params = {
|
||||
page: form.value.page,
|
||||
per_page: form.value.pageSize,
|
||||
@@ -172,7 +175,7 @@ const deleteItem = (item) => {
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#03B03C'
|
||||
})
|
||||
.then(async() => {
|
||||
.then(async () => {
|
||||
const res = await deleteSurveys(item.sn);
|
||||
if (res.data.message) {
|
||||
showToast(res.data.message);
|
||||
@@ -196,7 +199,7 @@ const copyItem = (item) => {
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#03B03C'
|
||||
})
|
||||
.then(async() => {
|
||||
.then(async () => {
|
||||
const res = await copySurveys(item.sn);
|
||||
if (res.data.code === 200 || res.data.code === 201) {
|
||||
showSuccessToast('复制成功');
|
||||
@@ -221,12 +224,21 @@ const toPreview = (item) => {
|
||||
});
|
||||
};
|
||||
const toPublish = (item) => {
|
||||
if (item.status === 1) {
|
||||
console.log(item);
|
||||
modify({ surveyPublishId: '' }).then((res) => {
|
||||
if (res.data) {
|
||||
// 吧 数据改掉
|
||||
}
|
||||
});
|
||||
} else {
|
||||
router.push({
|
||||
path: '/publish',
|
||||
query: {
|
||||
sn: item.sn
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
const editItem = (item) => {
|
||||
router.push({
|
||||
@@ -237,7 +249,7 @@ const editItem = (item) => {
|
||||
});
|
||||
};
|
||||
// 保存为模板
|
||||
const saveTemplate = async(item) => {
|
||||
const saveTemplate = async (item) => {
|
||||
const data = JSON.parse(JSON.stringify(item));
|
||||
const res = await saveTemplates(item.sn, data);
|
||||
if (res.data.code === 200 || res.data.code === 201) {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
v-model="questionInfo.survey.title"
|
||||
className="content-title"
|
||||
:active="true"
|
||||
placeholder="请输入问卷标题"
|
||||
@blur="saveTitle"
|
||||
></contenteditable>
|
||||
<!-- 问卷标注-->
|
||||
@@ -14,6 +15,7 @@
|
||||
v-model="questionInfo.survey.introduction"
|
||||
className="introduction"
|
||||
:active="true"
|
||||
placeholder="请输入问卷标注"
|
||||
@blur="saveTitle"
|
||||
></contenteditable>
|
||||
</div>
|
||||
@@ -570,7 +572,7 @@ const previewQuestion = () => {
|
||||
router.push({ name: 'preview', query: { ...route.query } });
|
||||
};
|
||||
|
||||
onMounted(async() => {
|
||||
onMounted(async () => {
|
||||
await getQuestionDetail();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -559,7 +559,7 @@ const {
|
||||
|
||||
// 第一次进入页面清空答案
|
||||
|
||||
//初始化页面到第一页
|
||||
// 初始化页面到第一页
|
||||
questionsData.value?.questions && clearAnswer(questionsData.value.questions);
|
||||
page.value = 1;
|
||||
console.log(questionsData.value);
|
||||
@@ -683,9 +683,9 @@ async function answer(callback, callbackBeforePage) {
|
||||
question.error = translatedText.value.ThisIsARequiredQuestion;
|
||||
}
|
||||
} else if (
|
||||
answer &&
|
||||
questionType === 1 &&
|
||||
Object.keys(answer).findIndex((value) => !answer[value]) !== -1
|
||||
answer
|
||||
&& questionType === 1
|
||||
&& Object.keys(answer).findIndex((value) => !answer[value]) !== -1
|
||||
) {
|
||||
// 单选题
|
||||
isError = true;
|
||||
@@ -865,16 +865,16 @@ async function answer(callback, callbackBeforePage) {
|
||||
// eslint-disable-next-line
|
||||
const reg =
|
||||
/^[a-zA-Z·~!@#¥%…&*()—\-+={}|《》?:“”【】、;‘’,。`!$^()_<>?:",./;'\\[\]]+$/;
|
||||
isError =
|
||||
config.include_mark === 1
|
||||
isError
|
||||
= config.include_mark === 1
|
||||
? !reg.test(newValue) || !newValue.length
|
||||
: !/^[a-zA-Z]+$/.test(newValue) || !newValue.length;
|
||||
question.error = isError ? translatedText.value.PleaseEnterEnglishLetters : '';
|
||||
break;
|
||||
// 中文
|
||||
case 4:
|
||||
isError =
|
||||
config.include_mark === 1
|
||||
isError
|
||||
= config.include_mark === 1
|
||||
? !/^(?:[\u3400-\u4DB5\u4E00-\u9FEA\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|[a-zA-Z·~!@#¥%…&*()—\-+={}|《》?:“”【】、;‘’,。`!$^()_<>?:",./;'\\[\]])+$/.test(
|
||||
newValue
|
||||
) || !newValue.length
|
||||
@@ -885,8 +885,8 @@ async function answer(callback, callbackBeforePage) {
|
||||
break;
|
||||
// 邮箱
|
||||
case 5:
|
||||
isError =
|
||||
!/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
|
||||
isError
|
||||
= !/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(
|
||||
value
|
||||
);
|
||||
question.error = isError ? translatedText.value.PleaseEnterACorrectEmail : '';
|
||||
@@ -898,8 +898,8 @@ async function answer(callback, callbackBeforePage) {
|
||||
break;
|
||||
// 身份证号
|
||||
case 7:
|
||||
isError =
|
||||
!/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/.test(
|
||||
isError
|
||||
= !/^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/.test(
|
||||
value
|
||||
);
|
||||
question.error = isError ? translatedText.value.PleaseEnterACorrectID : '';
|
||||
@@ -1041,14 +1041,14 @@ async function answer(callback, callbackBeforePage) {
|
||||
currentQuestions.forEach((question, index) => {
|
||||
if (index >= warnStart && index < warnEnd) {
|
||||
if (repeat.repeat_type) {
|
||||
question.warning =
|
||||
translatedText.value.TheAnswerIsRepeatedMoreThanOneTimesPleaseRevise(
|
||||
question.warning
|
||||
= translatedText.value.TheAnswerIsRepeatedMoreThanOneTimesPleaseRevise(
|
||||
repeat.allow_repeat_num,
|
||||
repeat.repeat_type
|
||||
);
|
||||
} else {
|
||||
question.error =
|
||||
translatedText.value.TheAnswerIsRepeatedMoreThanOneTimesPleaseRevise(
|
||||
question.error
|
||||
= translatedText.value.TheAnswerIsRepeatedMoreThanOneTimesPleaseRevise(
|
||||
repeat.allow_repeat_num,
|
||||
repeat.repeat_type
|
||||
);
|
||||
@@ -1395,8 +1395,8 @@ function updateAnswer(auto) {
|
||||
const evt1 = {};
|
||||
|
||||
if ([1].includes(question.question_type)) {
|
||||
evt1.value =
|
||||
Object.keys(question.answer)
|
||||
evt1.value
|
||||
= Object.keys(question.answer)
|
||||
.map((key) => (question.answer[key] ? key : undefined))
|
||||
.filter((i) => !!i)?.[0] || undefined;
|
||||
evt1.options = question.list.flatMap((i) => i.options);
|
||||
|
||||
@@ -196,7 +196,7 @@ watch(status, (val) => {
|
||||
getCode();
|
||||
}
|
||||
});
|
||||
onMounted(async () => {
|
||||
onMounted(async() => {
|
||||
fetchInfo();
|
||||
});
|
||||
</script>
|
||||
@@ -211,10 +211,10 @@ onMounted(async () => {
|
||||
|
||||
.content {
|
||||
margin: 10px;
|
||||
padding-bottom: 25px;
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
|
||||
padding-bottom: 25px;
|
||||
|
||||
.qrcode {
|
||||
display: flex;
|
||||
@@ -234,8 +234,8 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.desc {
|
||||
font-size: 13px;
|
||||
margin-top: 8px;
|
||||
font-size: 13px;
|
||||
line-height: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user