Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add question limited setting #115

Merged
merged 5 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ declare module 'vue' {
ElInput: typeof import('element-plus/es')['ElInput']
ElOption: typeof import('element-plus/es')['ElOption']
ElPagination: typeof import('element-plus/es')['ElPagination']
ElRadio: typeof import('element-plus/es')['ElRadio']
ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
ElSelect: typeof import('element-plus/es')['ElSelect']
ElSkeleton: typeof import('element-plus/es')['ElSkeleton']
ElSwitch: typeof import('element-plus/es')['ElSwitch']
Expand Down
22 changes: 22 additions & 0 deletions src/apis/service/User/verifyApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { request } from "@/apis/axios";
//import CryptoJS from 'crypto-js';

/*
const urlen =

const urlde =
*/
// 定义参数的类型
type verifyData = {
stu_id: string,
password :string,
survey_id: number
}
const verifyAPI = (data: verifyData ) => {
return request("/api/user/oauth", {
method: "POST",
data: data,
});
};

export default verifyAPI;
2 changes: 1 addition & 1 deletion src/components/Modal/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="text-3xl font-bold">
<slot name="title" ></slot>
</span>
<div class="flex items-center my-20 text-lg">
<div class=" my-20 text-lg flex-warp ">
<slot></slot>
</div>
<div class="modal-action flex justify-end gap-10" :class="[centerBtn ? 'flex justify-center' : undefined]">
Expand Down
23 changes: 21 additions & 2 deletions src/pages/DetailInfo/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
<span class="w-50">问题描述</span>
<textarea type="text" placeholder="Describe" class="dark:bg-customGray_more_shallow textarea textarea-bordered shadow-md w-full h-70 " v-model="localDescribe"/>
</div>
<span class="my-10 flex justify-between">
<span>最大多选数<input type="text" class="dark:bg-customGray_more_shallow input shadow-md w-55 h-40 ml-10" v-model.number="localMax"/></span>
<span>最小多选数<input type="text" class="dark:bg-customGray_more_shallow input shadow-md w-55 h-40 ml-10" v-model.number="localMin"/></span>
</span>
</div>
<div class="flex-col justify-center items-center">
<div class="flex gap-10">
Expand All @@ -28,7 +32,8 @@
<input type="checkbox" class="checkbox-sm" v-model="localOtherOption"/>
</span>
<div class="flex-col p-5 overflow-y-auto h-180 mt-10" ref="scrollContainer" style="scroll-behavior: smooth;" >
<div v-for="item in localOptions" :key="item.serial_num" class="flex items-center gap-10 my-5">
<div v-for="item in localOptions" :key="item.serial_num" class="my-5">
<div class="flex items-center gap-10">
<input type="checkbox" :name="item.serial_num" class="checkbox-sm my-5" />
<input type="text" class="dark:bg-customGray_more_shallow input input-bordered h-40 shadow-md" placeholder="option" v-model="item.content" />
<div class="ml-10 flex items-center gap-20">
Expand All @@ -38,12 +43,13 @@
<input type="file" class="dark:bg-customGray_more_shallow file-input file-input-bordered file-input-sm w-7/12" @change="handleFileChange($event, item.serial_num)" />
</div>
<button class="btn dark:bg-customGray_more_shallow dark:text-white btn-sm shadow-md" @click="deleteOption(item.serial_num)">删除</button>
</div>
</div>
</div>
<div class="divider"></div>
<div class="mt-20 flex justify-evenly items-center">
<button class="btn btn-accent dark:opacity-75 shadow-md dark:text-white" @click="addOption">新增选项</button>
<button class="btn btn-error dark:opacity-75 shadow-md shadow-md dark:text-white" @click="$emit('on-click')">删除题目</button>
<button class="btn btn-error dark:opacity-75 shadow-md dark:text-white" @click="$emit('on-click')">删除题目</button>
</div>
</div>
</template>
Expand All @@ -61,6 +67,8 @@ const props = defineProps<{
unique: boolean,
otherOption: boolean,
describe: string,
maximum_option: number,
minimum_option: number,
options?: {
content: string;
img: string;
Expand All @@ -78,6 +86,9 @@ const localUnique = ref<boolean>(props.unique);
const localOtherOption = ref<boolean>(props.otherOption);
const localDescribe = ref<string>(props.describe || '');
const localOptions = ref(props.options );
const localMax = ref(props.maximum_option)
const localMin = ref(props.minimum_option)


const handleFileChange = async (event, serial_num: number) => {
const file = event.target.files[0];
Expand Down Expand Up @@ -163,6 +174,14 @@ watch(localUnique, (newUnique) => {
watch(localDescribe, (newLocalDescribe) => {
emits('update:describe', newLocalDescribe);
});
watch(localMin, (newMin) => {
emits('update:minimum_option', Number(newMin));
});

watch(localMax, (newMax) => {
emits('update:maximum_option', Number(newMax));
});


watch(localOtherOption, (newOtherOption) => {
emits('update:otherOption', newOtherOption);
Expand Down
41 changes: 25 additions & 16 deletions src/pages/DetailInfo/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,25 @@
<div class="flex-col justify-center">
<el-skeleton :loading="loading" :rows="1" animated style="height: 60px">
<template #default>
<span class="flex gap-20 items-center"><span class="text-2xl">问卷标题</span><input type="text" placeholder="标题"
<span class="flex gap-20 items-center"><span class="text-2xl">问卷标题</span><input type="text" placeholder="标题"
class="input input-bordered dark:bg-customGray_shallow w-300" v-model="submitData.title" /></span>
<div class="flex items-top gap-20 my-15" >
<span>问卷内容描述</span>
<textarea class="dark:bg-customGray_shallow textarea textarea-bordered w-300" placeholder="描述问卷" v-model="submitData.desc" ></textarea>
</div>
<div class="flex gap-20 items-center my-15">
<span >问卷截止时间</span>
<el-date-picker
v-model="time"
type="datetime"
placeholder="截止时间"
:clearable="false"
/>
</div>

<div class="flex items-center my-15 gap-40">
<span class="flex items-center gap-15">每日最多提交<input type="text" v-model.number="submitData.day_limit" class="input input-bordered dark:bg-customGray_shallow w-50" /></span><span class="flex items-center gap-20">是否统一登录<input type="checkbox" class="checkbox-sm my-5" v-model="submitData.verify" /></span>
</div>
<div class="flex gap-20 items-center my-15">
<span >问卷截止时间</span>
<el-date-picker
v-model="time"
type="datetime"
placeholder="截止时间"
:clearable="false"
/>
</div>
</template>
</el-skeleton>
</div>
Expand All @@ -109,13 +113,13 @@
group="people"
@update="onUpdate"
>-->
<VueDraggableNext
<VueDraggableNext
v-model="question"
:animation="300"
:animation="300"
ghost-class="ghost"
@end="updateQuestionSerialNumbers"
>

<div v-for="q in question" :key="q.serial_num" >
<!-- 根据问题类型渲染组件 -->
<div v-if="q.question_type === 1">
Expand All @@ -129,7 +133,7 @@
<skeleton-card></skeleton-card>
</template>
<template #default>
<checkbox v-model:title="q.subject" v-model:options="q.options" v-model:serial_num="q.serial_num" @on-click="deleteQuestion(q.serial_num)" v-model:unique="q.unique" v-model:option-choose="q.required" v-model:other-option="q.other_option" v-model:describe="q.description"></checkbox>
<checkbox v-model:title="q.subject" v-model:options="q.options" v-model:serial_num="q.serial_num" @on-click="deleteQuestion(q.serial_num)" v-model:unique="q.unique" v-model:option-choose="q.required" v-model:other-option="q.other_option" v-model:describe="q.description" v-model:maximum_option="q.maximum_option" v-model:minimum_option="q.minimum_option"></checkbox>
</template>
</el-skeleton>
</div>
Expand Down Expand Up @@ -233,7 +237,9 @@ import SkeletonCard from "@/pages/DetailInfo/skeletonCard.vue";
import router from "@/router";
import {closeLoading, startLoading} from "@/utilities";
import {VueDraggableNext} from "vue-draggable-next"
import {useMainStore} from "@/stores";

const tempStore = useMainStore().useTempStore()
const selectedOption = ref(1);
const selectedNumber = ref(1);
const formData = ref();
Expand Down Expand Up @@ -273,7 +279,10 @@ onMounted(() => {
questions: [],
status: -1,
time: '',
title: ''
title: '',
day_limit: 0,
survey_type: tempStore.surveyType.value,
verify: false
}
loading.value = false
}
Expand Down Expand Up @@ -395,7 +404,7 @@ const dataReverse = () => {
const submit = (state:number) => {
submitData.value.time = time.value
submitData.value.questions = question.value;
// console.log(question.value);
console.log(question.value);
if(isNew === 'false') {
useRequest(() => setQuestionnaireDetailAPI(submitData.value), {
onBefore: () => startLoading(),
Expand Down
24 changes: 22 additions & 2 deletions src/pages/Home/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,29 @@
/>
</el-skeleton>
</div>
<modal :modal-id="'select'">
<template #title>创建问卷</template>
<template #default>
<span class="flex items-center">请选择创建问卷的类型
<el-radio-group v-model="surveyType" style="margin-left: 30px" >
<el-radio-button value="0" size="middle" label="调研问卷" />
<el-radio-button value="1" size="middle" label="投票问卷" />
</el-radio-group>
</span>
</template>
<template #action>
<div class="btn btn-success dark:opacity-70 dark:text-white w-80" @click="newQues">创建</div>
</template>
</modal>
</div>
</template>

<script setup lang="ts">
import { modal, showModal } from '@/components';
import questionnaireItem from './questionnaireItem.vue';
import { useRequest } from 'vue-hooks-plus';
import { getQuestionnaireListAPI } from '@/apis';
import {onMounted, ref} from 'vue';
import {nextTick, onMounted, ref} from 'vue';

Check warning on line 48 in src/pages/Home/index.vue

View workflow job for this annotation

GitHub Actions / CI

'nextTick' is defined but never used
import router from '@/router';
import {closeLoading, startLoading} from "@/utilities";
import { useMainStore } from '@/stores';
Expand All @@ -42,6 +57,7 @@
const totalPageNum = ref(1);
const questionnaireList = ref();
const loading = ref(true);
const surveyType = ref(tempStore.surveyType.value)
onMounted(() => {
loginStore.setShowHeader(true);
})
Expand Down Expand Up @@ -70,8 +86,12 @@
}

const addNewQuestionnaire = () => {
showModal("select")
}

const newQues = () => {
showModal('select', true)
localStorage.setItem('isNew','true')
router.push('/admin/DetailInfo')
}

</script>
3 changes: 3 additions & 0 deletions src/pages/View/checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
</div>
<div class="divider my-5"></div>
<div class="flex-col p-5 h-auto">
<span class="dark:opacity-80 text-gray-700 dark:text-gray-400 text-sm my-5" v-if="props.minimum_option !== 0">最少选 {{ props.minimum_option }} 个&ensp;</span><span class="dark:opacity-80 text-gray-700 dark:text-gray-400 text-sm my-5" v-if="props.maximum_option !== 0">最多选 {{ props.maximum_option }} 个</span>
<div v-for="item in localOptions" :key="item.serial_num" class="flex items-center gap-10 my-5">
<input type="checkbox" :name="props.serial_num" class="my-5" style="zoom: 140%" :value="item.content" v-model="answerArr"/>
<span v-if="item.content" class="text-sm">{{ item.content }}</span>
Expand Down Expand Up @@ -52,6 +53,8 @@ const props = defineProps<{
otherOption: boolean,
describe: string,
answer: string,
maximum_option: number,
minimum_option: number,
options?: {
content: string;
img: string;
Expand Down
Loading
Loading