mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/fe-manage.git
synced 2025-12-12 04:16:47 +08:00
-- fix bug
This commit is contained in:
@@ -18,43 +18,25 @@
|
||||
/>
|
||||
</div>
|
||||
<div style="display: flex; flex-direction: row; padding-top: 0px; margin-top: 20px; margin-left: 32px;">
|
||||
<div v-if="taskIndex >= 0">
|
||||
<button
|
||||
v-if="isOuter==1"
|
||||
style="width: 100px; cursor: pointer;"
|
||||
@click="changeOuter(1)"
|
||||
:class="isOuter == 1 ? 'outer' : 'notOuter'"
|
||||
>
|
||||
系统考试
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
style="width: 100px; cursor: pointer;"
|
||||
@click="changeOuter(2)"
|
||||
:class="isOuter == 2 ? 'outer' : 'notOuter'"
|
||||
>
|
||||
外部考试
|
||||
</button>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div>
|
||||
<button
|
||||
style="width: 100px; cursor: pointer;"
|
||||
@click="changeOuter(1)"
|
||||
:class="isOuter == 1 ? 'outer' : 'notOuter'"
|
||||
:class="formData.examType === 1 ? 'outer' : 'notOuter'"
|
||||
>
|
||||
系统考试
|
||||
</button>
|
||||
<button
|
||||
style="width: 100px; cursor: pointer;"
|
||||
@click="changeOuter(2)"
|
||||
:class="isOuter == 2 ? 'outer' : 'notOuter'"
|
||||
:class="formData.examType === 2 ? 'outer' : 'notOuter'"
|
||||
>
|
||||
外部考试
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isOuter===1" class="contentMain">
|
||||
<div v-if="formData.examType===1" class="contentMain">
|
||||
<div class="main_left">
|
||||
<div class="main_item">
|
||||
<div class="signbox">
|
||||
@@ -68,7 +50,6 @@
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-input
|
||||
:disabled="taskIndex >= 0"
|
||||
v-model:value="formData.examinationName"
|
||||
style="width: 400px; height: 40px; border-radius: 8px"
|
||||
placeholder="请输入考试名称"
|
||||
@@ -89,13 +70,13 @@
|
||||
</div>
|
||||
<s-test v-model:id="formData.examinationTestId" v-model:name="formData.examinationTestName">
|
||||
<div class="btnbox">
|
||||
<button class="xkbtn" @click="selectTest" :disabled="taskIndex >= 0">
|
||||
<button class="xkbtn" style="margin:0">
|
||||
{{ formData.examinationTestId ? "重选" : "选择" }}试卷
|
||||
</button>
|
||||
</div>
|
||||
</s-test>
|
||||
<div v-if="formData.examinationTestId">
|
||||
<a-tag closable color="processing" @close="delTag" :closeIcon="taskIndex >= 0">
|
||||
<a-tag closable color="processing" @close="delTag" :closeIcon="true">
|
||||
<span style="font-size: 14px; line-height: 33px">{{ formData.examinationTestName }}</span>
|
||||
</a-tag>
|
||||
</div>
|
||||
@@ -116,8 +97,8 @@
|
||||
style="width: 400px; height: 40px; border-radius: 8px"
|
||||
:show-time="{format:'hh:mm'}"
|
||||
:disabled-date="disabledDate"
|
||||
:disabled-time="disabledRangeTime"
|
||||
format="YYYY/MM/DD HH:mm"
|
||||
format="YYYY-MM-DD HH:mm"
|
||||
valueFormat="YYYY-MM-DD HH:mm"
|
||||
v-model:value="dateTime"
|
||||
@change="timeChange"
|
||||
:placeholder="[' 开始时间', ' 结束时间']"
|
||||
@@ -136,7 +117,6 @@
|
||||
</div>
|
||||
<div class="select">
|
||||
<a-input-number
|
||||
:disabled="taskIndex >= 0"
|
||||
:min="0"
|
||||
:max="300"
|
||||
:precision="0"
|
||||
@@ -158,7 +138,6 @@
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-input
|
||||
:disabled="taskIndex >= 0"
|
||||
v-model:value="formData.passLine"
|
||||
type="number"
|
||||
style="width: 400px; height: 40px; border-radius: 8px"
|
||||
@@ -173,7 +152,6 @@
|
||||
</div>
|
||||
<div class="textarea">
|
||||
<a-textarea
|
||||
:disabled="taskIndex >= 0"
|
||||
v-model:value="formData.examinationExplain"
|
||||
placeholder="请输入考试说明"
|
||||
allow-clear
|
||||
@@ -192,7 +170,6 @@
|
||||
<div class="timerbox">
|
||||
<span>允许重复考试:</span>
|
||||
<a-input-number
|
||||
:disabled="taskIndex >= 0"
|
||||
:min="-1"
|
||||
:max="300"
|
||||
:precision="0"
|
||||
@@ -217,7 +194,6 @@
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-radio-group
|
||||
:disabled="taskIndex >= 0"
|
||||
style="margin-right: 12px"
|
||||
v-model:value="formData.showAnswers"
|
||||
>
|
||||
@@ -232,7 +208,6 @@
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-radio-group
|
||||
:disabled="taskIndex >= 0"
|
||||
style="margin-right: 12px"
|
||||
v-model:value="formData.showAnalysis"
|
||||
>
|
||||
@@ -247,7 +222,6 @@
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-radio-group
|
||||
:disabled="taskIndex >= 0"
|
||||
style="margin-right: 12px"
|
||||
v-model:value="formData.scoringModel"
|
||||
>
|
||||
@@ -264,7 +238,6 @@
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-radio-group
|
||||
:disabled="taskIndex >= 0"
|
||||
style="margin-right: 12px"
|
||||
v-model:value="formData.questionArrangement"
|
||||
>
|
||||
@@ -292,7 +265,7 @@
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-input
|
||||
v-model:value="formDataOuter.examinationName"
|
||||
v-model:value="formData.examinationName"
|
||||
style="width: 400px; height: 40px; border-radius: 8px"
|
||||
placeholder="请输入考试名称"
|
||||
:maxlength="20"
|
||||
@@ -311,7 +284,7 @@
|
||||
</div>
|
||||
<div class="btnbox">
|
||||
<a-input
|
||||
v-model:value="formDataOuter.source"
|
||||
v-model:value="formData.source"
|
||||
style="width: 400px; height: 40px; border-radius: 8px"
|
||||
placeholder="请输入数据来源"
|
||||
:maxlength="20"
|
||||
@@ -324,7 +297,7 @@
|
||||
</div>
|
||||
<div class="textarea">
|
||||
<a-textarea
|
||||
v-model:value="formDataOuter.externalExplain"
|
||||
v-model:value="formData.externalExplain"
|
||||
placeholder="请输入考试说明"
|
||||
allow-clear
|
||||
show-count
|
||||
@@ -337,75 +310,109 @@
|
||||
</div>
|
||||
<div class="main_btns">
|
||||
<a-button class="btn1" @click="closeDrawer">取消</a-button>
|
||||
<a-button v-if="isOuter==1" class="btn2" @click="confirm">确定</a-button>
|
||||
<a-button v-else class="btn2" @click="confirmouter">确定</a-button>
|
||||
<a-button class="btn2" @click="confirm">确定</a-button>
|
||||
</div>
|
||||
<!-- 加载动画 -->
|
||||
<div class="aeLoading" :style="{ display: addLoading ? 'flex' : 'none' }">
|
||||
<a-spin :spinning="addLoading" tip=""/>
|
||||
</div>
|
||||
<!-- 选择考试抽屉 -->
|
||||
<s-test v-model:STvisible="STvisible" @getSTData="getData"/>
|
||||
</div>
|
||||
</a-drawer>
|
||||
</template>
|
||||
<script setup>
|
||||
import {defineEmits, defineProps, ref} from "vue";
|
||||
import {defineEmits, defineProps, ref, watch} from "vue";
|
||||
import STest from "./SelectTest.vue";
|
||||
import dayjs from "dayjs";
|
||||
import {message} from "ant-design-vue";
|
||||
import {Form, message} from "ant-design-vue";
|
||||
|
||||
const props = defineProps({
|
||||
type: Number,
|
||||
taskList: []
|
||||
})
|
||||
const visible = ref(false)
|
||||
const formData = ref({
|
||||
const initValue = {
|
||||
examinationName: '',
|
||||
examinationTestId: '',
|
||||
examinationStartTime: '',
|
||||
examinationEndTime: '',
|
||||
examinationDuration: '',
|
||||
passLine: '',
|
||||
examType: 1,
|
||||
source: "",
|
||||
showAnswers: 2,
|
||||
showAnalysis: 2,
|
||||
scoringModel: 2,
|
||||
questionArrangement: 4
|
||||
})
|
||||
|
||||
const formDataOuter = ref({
|
||||
examType: 2,
|
||||
examinationName:"",
|
||||
source:"",
|
||||
externalExplain:""
|
||||
})
|
||||
questionArrangement: 4,
|
||||
externalExplain: ""
|
||||
}
|
||||
const formData = ref(initValue)
|
||||
const innerRule = {
|
||||
examinationName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入考试名称',
|
||||
},
|
||||
],
|
||||
examinationTestId: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入选择试卷',
|
||||
},
|
||||
],
|
||||
examinationStartTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入开始开始时间',
|
||||
},
|
||||
],
|
||||
examinationEndTime: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入开始结束时间',
|
||||
},
|
||||
],
|
||||
examinationDuration: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入考试时长',
|
||||
},
|
||||
],
|
||||
passLine: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入及格线',
|
||||
},
|
||||
],
|
||||
}
|
||||
const outerRule = {
|
||||
examinationName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入考试名称',
|
||||
},
|
||||
],
|
||||
source: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入数据来源',
|
||||
},
|
||||
],
|
||||
}
|
||||
const rulesRef = ref(innerRule);
|
||||
|
||||
const emit = defineEmits({})
|
||||
const taskIndex = ref(-1);
|
||||
const dateTime = ref([]);
|
||||
const isOuter = ref(1);
|
||||
|
||||
const {resetFields, validate} = Form.useForm(formData, rulesRef);
|
||||
|
||||
watch(() => formData.value.examType, () => {
|
||||
formData.value.examType === 1 ? rulesRef.value = innerRule : rulesRef.value = outerRule
|
||||
})
|
||||
|
||||
const closeDrawer = () => {
|
||||
visible.value = false
|
||||
taskIndex.value = -1
|
||||
formData.value = {
|
||||
examType: 1,
|
||||
showAnswers: 2,
|
||||
showAnalysis: 2,
|
||||
scoringModel: 2,
|
||||
questionArrangement: 4
|
||||
}
|
||||
formDataOuter.value = ref({
|
||||
examType: 2,
|
||||
examinationName:"",
|
||||
source:"",
|
||||
externalExplain:""
|
||||
})
|
||||
resetFields()
|
||||
dateTime.value = []
|
||||
};
|
||||
|
||||
// const range = (start, end) => {
|
||||
// const result = [];
|
||||
// for (let i = start; i < end; i++) {
|
||||
// result.push(i);
|
||||
// }
|
||||
// return result;
|
||||
// };
|
||||
|
||||
function timeChange(time, timeStr) {
|
||||
formData.value.examinationStartTime = timeStr[0]
|
||||
@@ -416,39 +423,13 @@ const disabledDate = (current) => {
|
||||
return current && current < dayjs().startOf('day');
|
||||
};
|
||||
|
||||
const disabledRangeTime = () => ({
|
||||
// disabledHours: () => range(0, 24).splice(4, 20),
|
||||
// disabledMinutes: () => range(30, 60),
|
||||
// disabledSeconds: () => [55, 56],
|
||||
});
|
||||
|
||||
// 系统考试
|
||||
function confirm() {
|
||||
if (!formData.value.examinationName) {
|
||||
message.warning("请输入考试名称");
|
||||
return
|
||||
}
|
||||
if (!formData.value.examinationTestId) {
|
||||
message.warning("请输入选择试卷");
|
||||
return
|
||||
}
|
||||
if (!formData.value.examinationStartTime) {
|
||||
message.warning("请输入开始结束时间");
|
||||
return
|
||||
}
|
||||
if (!formData.value.examinationEndTime) {
|
||||
message.warning("请输入开始结束时间");
|
||||
return
|
||||
}
|
||||
if (!formData.value.examinationDuration) {
|
||||
message.warning("请输入考试时长");
|
||||
return
|
||||
}
|
||||
if (!formData.value.passLine) {
|
||||
message.warning("请输入及格线");
|
||||
return
|
||||
}
|
||||
// debugger
|
||||
async function confirm() {
|
||||
await validate().catch(({errorFields}) => {
|
||||
message.warning(errorFields[0].errors.join());
|
||||
throw Error("数据校验不通过")
|
||||
});
|
||||
if (taskIndex.value === -1) {
|
||||
const list = props.taskList
|
||||
list.push({name: formData.value.examinationName, type: props.type, info: {...formData.value}})
|
||||
@@ -456,44 +437,17 @@ function confirm() {
|
||||
const data = props.taskList[taskIndex.value]
|
||||
data.name = formData.value.examinationName
|
||||
data.info = formData.value
|
||||
data.examType = formData.value == 1 ? 1 : 2
|
||||
}
|
||||
emit('update:taskList', [...props.taskList])
|
||||
closeDrawer()
|
||||
}
|
||||
|
||||
// 外部考试
|
||||
function confirmouter() {
|
||||
if (!formDataOuter.value.examinationName) {
|
||||
message.warning("请输入考试名称");
|
||||
return
|
||||
}
|
||||
if (!formDataOuter.value.source) {
|
||||
message.warning("请输入数据来源");
|
||||
return
|
||||
}
|
||||
|
||||
if (taskIndex.value === -1) {
|
||||
const list = props.taskList
|
||||
list.push({name: formDataOuter.value.examinationName,duration:dayjs(formData.value.examinationEndTime).diff(formData.value.examinationStartTime,'minutes'), type: props.type, info: {...formDataOuter.value}})
|
||||
} else {
|
||||
const data = props.taskList[taskIndex.value]
|
||||
data.name = formDataOuter.value.examinationName
|
||||
data.info = formDataOuter.value
|
||||
data.examType = 2
|
||||
data.duration = dayjs(formData.value.examinationEndTime).diff(formData.value.examinationStartTime,'minutes')
|
||||
}
|
||||
emit('update:taskList', [...props.taskList])
|
||||
closeDrawer()
|
||||
}
|
||||
|
||||
function openDrawer(i, row) {
|
||||
row && row.info.examType == 1 ? row && (formData.value = row.info) : row && (formDataOuter.value = row.info);
|
||||
row ? isOuter.value = row.info.examType : isOuter.value = 1;
|
||||
row && row.info.examType == 1 && (dateTime.value = [dayjs(row.info.examinationStartTime, "YYYY-MM-DD HH:mm"), dayjs(row.info.examinationEndTime, "YYYY-MM-DD HH:mm")]);
|
||||
row && resetFields(row.info);
|
||||
row && (dateTime.value = [row.info.examinationStartTime, row.info.examinationEndTime]);
|
||||
(i >= 0) && (taskIndex.value = i);
|
||||
visible.value = true
|
||||
|
||||
}
|
||||
|
||||
const delTag = () => {
|
||||
@@ -502,7 +456,7 @@ const delTag = () => {
|
||||
}
|
||||
|
||||
function changeOuter(v) {
|
||||
isOuter.value = v;
|
||||
formData.value.examType = v;
|
||||
}
|
||||
|
||||
defineExpose({openDrawer})
|
||||
|
||||
Reference in New Issue
Block a user