bug整改
This commit is contained in:
@@ -228,7 +228,9 @@ const basicForm = {
|
||||
}
|
||||
})
|
||||
} else {
|
||||
this.formData = {}
|
||||
this.formData = {
|
||||
category: 'QUIZ'
|
||||
}
|
||||
}
|
||||
},
|
||||
onSubmit() {
|
||||
|
||||
@@ -91,7 +91,7 @@ const subjectForm = {
|
||||
<div class="option-content">
|
||||
<el-input
|
||||
v-model="option.text"
|
||||
:placeholder="'选项'+optionIndex + 1">
|
||||
:placeholder="'选项' + (optionIndex + 1)">
|
||||
<template slot="prepend">选项{{optionIndex + 1}}</template>
|
||||
</el-input>
|
||||
<!-- <el-input-->
|
||||
@@ -119,7 +119,8 @@ const subjectForm = {
|
||||
<el-switch
|
||||
v-if="activity.category==='QUIZ'"
|
||||
v-model="option.isCorrect"
|
||||
active-text="正确答案">
|
||||
active-text="正确答案"
|
||||
@change="handleCorrectAnswerChange(subject, optionIndex)">
|
||||
</el-switch>
|
||||
|
||||
<el-button
|
||||
@@ -286,6 +287,12 @@ const subjectForm = {
|
||||
|
||||
//题目类型切换
|
||||
subjectTypeChange(subject, subjectIndex) {
|
||||
// 切换题型时先清空当前题目的正确答案状态,避免沿用旧题型下的答案配置。
|
||||
;(subject.options || []).forEach((option) => {
|
||||
if (option) {
|
||||
this.$set(option, 'isCorrect', false)
|
||||
}
|
||||
})
|
||||
if (subject.type === 'text') {
|
||||
subject.options = []
|
||||
}
|
||||
@@ -310,7 +317,7 @@ const subjectForm = {
|
||||
addOption(subject) {
|
||||
subject.options.push({
|
||||
id: this.generateId(),
|
||||
text: "选项" + subject.options.length + 1,
|
||||
text: "选项" + (subject.options.length + 1),
|
||||
hint: "",
|
||||
imgUrl: null,
|
||||
isCorrect: false
|
||||
@@ -393,10 +400,67 @@ const subjectForm = {
|
||||
|
||||
},
|
||||
|
||||
// 单选题切换正确答案时保持只有一个正确选项,避免界面状态与题型规则不一致。
|
||||
handleCorrectAnswerChange(subject, optionIndex) {
|
||||
if (!subject || subject.type !== 'radio') {
|
||||
return
|
||||
}
|
||||
const options = subject.options || []
|
||||
const currentOption = options[optionIndex]
|
||||
if (!currentOption || !currentOption.isCorrect) {
|
||||
return
|
||||
}
|
||||
for (let index = 0; index < options.length; index++) {
|
||||
if (index !== optionIndex) {
|
||||
this.$set(options[index], 'isCorrect', false)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 保存前校验选项内容,避免题目存在空选项或缺少正确答案时仍然提交到后端。
|
||||
validateSubjectOptions() {
|
||||
for (let subjectIndex = 0; subjectIndex < this.subjects.length; subjectIndex++) {
|
||||
const subject = this.subjects[subjectIndex]
|
||||
if (!subject || subject.type === 'text') {
|
||||
continue
|
||||
}
|
||||
const options = subject.options || []
|
||||
if (options.length === 0) {
|
||||
this.$message.warning('请设置第' + (subjectIndex + 1) + '题的选项')
|
||||
return false
|
||||
}
|
||||
let correctAnswerCount = 0
|
||||
for (let optionIndex = 0; optionIndex < options.length; optionIndex++) {
|
||||
const option = options[optionIndex]
|
||||
const optionText = option && option.text ? option.text.trim() : ''
|
||||
if (!optionText) {
|
||||
this.$message.warning('第' + (subjectIndex + 1) + '题的第' + (optionIndex + 1) + '个选项不能为空')
|
||||
return false
|
||||
}
|
||||
if (option && option.isCorrect) {
|
||||
correctAnswerCount++
|
||||
}
|
||||
}
|
||||
if (this.activity.category === 'QUIZ') {
|
||||
if (subject.type === 'radio' && correctAnswerCount > 1) {
|
||||
this.$message.warning('第' + (subjectIndex + 1) + '题为单选题,只能设置一个正确答案')
|
||||
return false
|
||||
}
|
||||
if (correctAnswerCount === 0) {
|
||||
this.$message.warning('第' + (subjectIndex + 1) + '题请至少设置一个正确答案')
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
},
|
||||
|
||||
//保存
|
||||
saveQuestionnaire() {
|
||||
$
|
||||
.post("/platform/qsv/activity/saveSubjects", {
|
||||
if (!this.validateSubjectOptions()) {
|
||||
return
|
||||
}
|
||||
$.post("/platform/qsv/activity/saveSubjects", {
|
||||
activityId: this.id,
|
||||
subjects: JSON.stringify(this.subjects)
|
||||
})
|
||||
|
||||
@@ -53,7 +53,7 @@ const answer = {
|
||||
$.post("/platform/qsv/survey/deleteUserAnswer", { id }).then((res) => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
this.list()
|
||||
this.pageData()()
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
+16
-4
@@ -189,7 +189,7 @@ const MEMBER_CHANGE = {
|
||||
<!-- <el-descriptions-item></el-descriptions-item>-->
|
||||
</template>
|
||||
|
||||
<el-descriptions-item label="会员状态" :span="1.5">
|
||||
<el-descriptions-item label="会员状态" >
|
||||
<el-form-item prop="member">
|
||||
<el-radio-group v-model="formData.member" size="small">
|
||||
<el-radio border :label="true">会员</el-radio>
|
||||
@@ -198,7 +198,7 @@ const MEMBER_CHANGE = {
|
||||
</el-form-item>
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="福利会员状态" :span="1.5">
|
||||
<el-descriptions-item label="福利会员状态">
|
||||
<el-form-item prop="welfareMember">
|
||||
<el-radio-group v-model="formData.welfareMember" size="small">
|
||||
<el-radio border :label="true">福利会员</el-radio>
|
||||
@@ -206,7 +206,17 @@ const MEMBER_CHANGE = {
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="入校时间">
|
||||
<el-form-item>
|
||||
<el-date-picker v-model="formData.arrivalAtSchoolDate"
|
||||
type="date"
|
||||
placeholder="请选择入校时间"
|
||||
format="yyyy-MM-dd"
|
||||
value-format="yyyy-MM-dd"></el-date-picker>
|
||||
</el-form-item>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item></el-descriptions-item>
|
||||
<el-descriptions-item></el-descriptions-item>
|
||||
<template v-if="formData.loginname == $store.state.user.loginname">
|
||||
<el-descriptions-item label="家庭主要成员" :span="3">
|
||||
<el-form-item prop="families">
|
||||
@@ -457,7 +467,8 @@ const MEMBER_CHANGE = {
|
||||
mobile,
|
||||
email,
|
||||
families,
|
||||
personalData
|
||||
personalData,
|
||||
arrivalAtSchoolDate
|
||||
} = this.user
|
||||
|
||||
this.$set(this.formData, "userId", id)
|
||||
@@ -488,6 +499,7 @@ const MEMBER_CHANGE = {
|
||||
this.$set(this.formData, "email", email)
|
||||
this.$set(this.formData, "families", families ? families : [])
|
||||
this.$set(this.formData, "personalData", personalData)
|
||||
this.$set(this.formData, "arrivalAtSchoolDate", arrivalAtSchoolDate)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -570,7 +570,6 @@ layout("/layouts/platform.html"){
|
||||
{ prop: "arrivalAtSchoolDate", label: "来校时间", width: 120, sortable: true, checked: 0 },
|
||||
{ prop: "teachingTime", label: "从教年月", width: 120, sortable: true, checked: 0 },
|
||||
{ prop: "expectedLeaveSchoolDate", label: "预计/最后离校时间", width: 120, sortable: true, checked: 0 },
|
||||
{ prop: "arrivalAtSchooDate", label: "入校时间", width: 120, sortable: true, checked: 0 },
|
||||
],
|
||||
|
||||
changeTypeData: [],
|
||||
|
||||
+45
-21
@@ -255,7 +255,27 @@
|
||||
"USER_STATE", "USER_PREPARED_BY_TYPE", "USER_PERSON_TYPE", "USER_MARRIAGE","AIDFUND_MEMBER_USER_TYPE","USER_ATTRIBUTE"],
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
formData: {},
|
||||
formRules: {
|
||||
loginname: [{ required: true, message: '请输入工号', trigger: 'blur' }],
|
||||
username: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
sex: [{ required: true, message: '请选择性别', trigger: 'change' }],
|
||||
idCard: [{ required: true, message: '请输入身份证号码', trigger: 'blur' }],
|
||||
mobile: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
|
||||
unitId: [{ required: true, message: '请选择工作单位', trigger: 'change' }],
|
||||
unionId: [{ required: true, message: '请选择所属工会', trigger: 'change' }],
|
||||
userState: [{ required: true, message: '请选择在职状态', trigger: 'change' }]
|
||||
},
|
||||
units: [],
|
||||
unions: [],
|
||||
submitLoading: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getDefaultFormData() {
|
||||
return {
|
||||
id: '',
|
||||
recordId: '',
|
||||
loginname: '',
|
||||
username: '',
|
||||
sex: '男',
|
||||
@@ -282,23 +302,26 @@
|
||||
specialty: '',
|
||||
member: false,
|
||||
welfareMember: false
|
||||
},
|
||||
formRules: {
|
||||
loginname: [{ required: true, message: '请输入工号', trigger: 'blur' }],
|
||||
username: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
|
||||
sex: [{ required: true, message: '请选择性别', trigger: 'change' }],
|
||||
idCard: [{ required: true, message: '请输入身份证号码', trigger: 'blur' }],
|
||||
mobile: [{ required: true, message: '请输入联系电话', trigger: 'blur' }],
|
||||
unitId: [{ required: true, message: '请选择工作单位', trigger: 'change' }],
|
||||
unionId: [{ required: true, message: '请选择所属工会', trigger: 'change' }],
|
||||
userState: [{ required: true, message: '请选择在职状态', trigger: 'change' }]
|
||||
},
|
||||
units: [],
|
||||
unions: [],
|
||||
submitLoading: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
},
|
||||
onOpen(params) {
|
||||
this.formData = this.getDefaultFormData()
|
||||
if (this.$refs.formRef) {
|
||||
this.$refs.formRef.resetFields()
|
||||
}
|
||||
if (params && params.recordId && params.userId) {
|
||||
// 编辑时回填当前补录记录,继续复用新增表单。
|
||||
$.post('/platform/member/info/input/findOne', params).then(res => {
|
||||
if (res.code === 0 && res.data) {
|
||||
this.formData = Object.assign(this.getDefaultFormData(), res.data)
|
||||
this.formData.families = this.formData.families || []
|
||||
}
|
||||
})
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs.formRef && this.$refs.formRef.clearValidate()
|
||||
})
|
||||
},
|
||||
async initUnits() {
|
||||
if (this.$auth.hasRoleOr(["SYSADMIN", "SCHOOL_UNION_ADMIN"])) {
|
||||
this.units = await this.$businessTool.listUnit()
|
||||
@@ -325,10 +348,10 @@
|
||||
type: "warning"
|
||||
}).then(() => {
|
||||
const loading = createLoading()
|
||||
this.$axios.post('/platform/member/info/input/add', this.formData).then(res => {
|
||||
const submitUrl = this.formData.recordId ? '/platform/member/info/input/update' : '/platform/member/info/input/add'
|
||||
this.$axios.post(submitUrl, this.formData).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.$message.success(res.msg)
|
||||
commonUtil.pjaxPush("/platform/member/info/input")
|
||||
}
|
||||
}).finally(() => {
|
||||
loading.close()
|
||||
@@ -338,11 +361,12 @@
|
||||
},
|
||||
handleCancel() {
|
||||
this.$refs.formRef.resetFields()
|
||||
this.formData.families = []
|
||||
this.formData = this.getDefaultFormData()
|
||||
this.$parent.$parent.close()
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.formData = this.getDefaultFormData()
|
||||
this.initUnits()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +78,10 @@ layout("/layouts/platform.html"){
|
||||
:prop="column.prop"
|
||||
:sortable="column.sortable"
|
||||
></el-table-column>
|
||||
<el-table-column label="操作" width="150px">
|
||||
<el-table-column label="操作" width="220px">
|
||||
<template slot-scope="{row}">
|
||||
<el-button @click="openView(row)" size="mini">查看</el-button>
|
||||
<el-button @click="openEdit(row)" size="mini" type="primary">编辑</el-button>
|
||||
<el-button @click="doDelete(row)" size="mini" type="danger">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
@@ -111,7 +112,7 @@ layout("/layouts/platform.html"){
|
||||
data() {
|
||||
return {
|
||||
pageForm: {
|
||||
year: new Date().getFullYear() - 1 + "",
|
||||
year: new Date().getFullYear() + "",
|
||||
memberSearchName: "",
|
||||
memberSearchKeyWord: ""
|
||||
},
|
||||
@@ -140,7 +141,15 @@ layout("/layouts/platform.html"){
|
||||
methods: {
|
||||
openAdd() {
|
||||
this.$refs.guava.edit(() => {
|
||||
// 可以在这里初始化表单数据
|
||||
this.$refs.memberAddFormRef.onOpen()
|
||||
})
|
||||
},
|
||||
openEdit(row) {
|
||||
this.$refs.guava.edit(() => {
|
||||
this.$refs.memberAddFormRef.onOpen({
|
||||
recordId: row.id,
|
||||
userId: row.userId
|
||||
})
|
||||
})
|
||||
},
|
||||
handleAddSuccess() {
|
||||
|
||||
@@ -245,6 +245,14 @@ layout("/layouts/platform_h5.html"){
|
||||
return
|
||||
}
|
||||
|
||||
const selectedOptionIds = subject.userSelectOptionIds || []
|
||||
const hasSelected = selectedOptionIds.includes(optionId)
|
||||
// 多选题达到最大可选数量后禁止继续勾选,但允许取消已选项。
|
||||
if (subject.type === "checkbox" && !hasSelected && subject.maxMulti && subject.maxMulti > 0 && selectedOptionIds.length >= subject.maxMulti) {
|
||||
this.$toast("本题最多选择" + subject.maxMulti + "项")
|
||||
return
|
||||
}
|
||||
|
||||
if (subject.type === "radio") {
|
||||
this.$refs["subject" + subject.id][0].toggleAll(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user