|
|
@@ -0,0 +1,738 @@
|
|
|
+<template>
|
|
|
+ <div class="p-2 page-container">
|
|
|
+ <transition :enter-active-class="sq_proxy?.animate.searchAnimate.enter" :leave-active-class="sq_proxy?.animate.searchAnimate.leave">
|
|
|
+ <div ref="sq_searchRef" v-show="sq_showSearch" class="mb-[10px]">
|
|
|
+ <el-card shadow="hover">
|
|
|
+ <el-form ref="sq_queryFormRef" :model="sq_queryParams" :inline="true">
|
|
|
+ <el-row :gutter="20">
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="题目标题" prop="questionTitle">
|
|
|
+ <el-input v-model="sq_queryParams.questionTitle" placeholder="请输入题目标题" clearable @keyup.enter="sq_handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="所属分类" prop="categoryId">
|
|
|
+ <el-select v-model="sq_queryParams.categoryId" placeholder="请选择所属分类" clearable @change="sq_handleQuery">
|
|
|
+ <el-option v-for="category in sq_satCategoryList" :key="category.id" :label="category.categoryName" :value="category.id" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="题目类型" prop="questionType">
|
|
|
+ <el-select v-model="sq_queryParams.questionType" placeholder="请选择题目类型" clearable>
|
|
|
+ <el-option v-for="dict in sq_sys_question_category" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="状态" prop="status">
|
|
|
+ <el-select v-model="sq_queryParams.status" placeholder="请选择状态" clearable>
|
|
|
+ <el-option v-for="dict in sq_sys_item_enable" :key="dict.value" :label="dict.label" :value="dict.value" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="24" class="search-btn-container">
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="Search" @click="sq_handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="Refresh" @click="sq_resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ </el-card>
|
|
|
+ </div>
|
|
|
+ </transition>
|
|
|
+
|
|
|
+ <el-card shadow="never" class="button-card table-card">
|
|
|
+ <template #header>
|
|
|
+ <el-row ref="sq_toolbarRef" :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="primary" plain icon="Plus" @click="sq_handleAdd" v-hasPermi="['hq:satQuestion:add']">新增</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button icon="Edit" :disabled="sq_single" @click="sq_handleUpdate()" v-hasPermi="['hq:satQuestion:edit']">修改</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button icon="Delete" :disabled="sq_multiple" @click="sq_handleDelete()" v-hasPermi="['hq:satQuestion:remove']">删除</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button icon="Download" @click="sq_handleExport" v-hasPermi="['hq:satQuestion:export']">导出</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar :showSearch="sq_showSearch" @queryTable="sq_getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+ </template>
|
|
|
+ <div class="table-container">
|
|
|
+ <el-table v-loading="sq_loading" border :data="sq_satQuestionList" @selection-change="sq_handleSelectionChange">
|
|
|
+ <el-table-column type="selection" width="55" align="center" />
|
|
|
+ <el-table-column label="题目标题" align="center" prop="questionTitle" width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tooltip
|
|
|
+ effect="dark"
|
|
|
+ :content="scope.row.questionTitle"
|
|
|
+ placement="top"
|
|
|
+ :show-after="100"
|
|
|
+ :hide-after="100"
|
|
|
+ popper-style="max-width: 300px; max-height: 200px;"
|
|
|
+ >
|
|
|
+ <div class="text-ellipsis">
|
|
|
+ {{ scope.row.questionTitle }}
|
|
|
+ </div>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="所属分类" align="center" prop="categoryId">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ sq_satCategoryAllList.find((cat) => cat.id == scope.row.categoryId)?.categoryName || '--' }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="分值" align="center" prop="score">
|
|
|
+ <template #default="scope">
|
|
|
+ {{ scope.row.score }}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="题目类型" align="center" prop="questionType">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :options="sq_sys_question_category" :value="scope.row.questionType" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="是否必填" align="center" prop="isRequired">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :options="sq_sys_item_required" :value="scope.row.isRequired" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="状态" align="center" prop="status">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :options="sq_sys_item_enable" :value="scope.row.status" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="备注" align="center" prop="remark" width="200">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tooltip
|
|
|
+ effect="dark"
|
|
|
+ :content="scope.row.remark"
|
|
|
+ placement="top"
|
|
|
+ :show-after="100"
|
|
|
+ :hide-after="100"
|
|
|
+ popper-style="max-width: 300px; max-height: 200px;"
|
|
|
+ >
|
|
|
+ <div class="text-ellipsis">
|
|
|
+ {{ scope.row.remark }}
|
|
|
+ </div>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tooltip content="设置选项" placement="top" v-if="scope.row.questionType === '1' || scope.row.questionType === '2'">
|
|
|
+ <el-button link type="success" icon="List" @click="sq_handleOptionManage(scope.row)" v-hasPermi="['hq:satOption:list']"></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-tooltip content="修改" placement="top">
|
|
|
+ <el-button link type="primary" icon="Edit" @click="sq_handleUpdate(scope.row)" v-hasPermi="['hq:satQuestion:edit']"></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ <el-tooltip content="删除" placement="top">
|
|
|
+ <el-button link type="danger" icon="Delete" @click="sq_handleDelete(scope.row)" v-hasPermi="['hq:satQuestion:remove']"></el-button>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <div class="pagination-container">
|
|
|
+ <pagination
|
|
|
+ v-show="sq_total > 0"
|
|
|
+ :total="sq_total"
|
|
|
+ :page="sq_queryParams.pageNum"
|
|
|
+ :limit="sq_queryParams.pageSize"
|
|
|
+ @pagination="sq_getList"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </el-card>
|
|
|
+
|
|
|
+ <!-- 添加或修改题库对话框 -->
|
|
|
+ <el-dialog :title="sq_dialog.title" v-model="sq_dialog.visible" width="500px" append-to-body>
|
|
|
+ <el-form ref="sq_satQuestionFormRef" :model="sq_form" :rules="sq_rules" label-width="80px">
|
|
|
+ <el-form-item label="题目标题" prop="questionTitle">
|
|
|
+ <el-input v-model="sq_form.questionTitle" type="textarea" resize="none" :autosize="false" :rows="4" placeholder="请输入题目标题" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="所属分类" prop="categoryId">
|
|
|
+ <el-select v-model="sq_form.categoryId" placeholder="请选择所属分类">
|
|
|
+ <el-option v-for="category in sq_satCategoryList" :key="category.id" :label="category.categoryName" :value="category.id" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="题目类型" prop="questionType">
|
|
|
+ <el-select v-model="sq_form.questionType" placeholder="请选择题目类型">
|
|
|
+ <el-option v-for="dict in sq_sys_question_category" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="是否必填" prop="isRequired">
|
|
|
+ <el-select v-model="sq_form.isRequired" placeholder="请选择是否必填">
|
|
|
+ <el-option v-for="dict in sq_sys_item_required" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态" prop="status">
|
|
|
+ <el-select v-model="sq_form.status" placeholder="请选择状态">
|
|
|
+ <el-option v-for="dict in sq_sys_item_enable" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注" prop="remark">
|
|
|
+ <el-input v-model="sq_form.remark" type="textarea" resize="none" :autosize="false" :rows="4" placeholder="请输入内容" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button :loading="sq_buttonLoading" type="primary" @click="sq_submitForm">确 定</el-button>
|
|
|
+ <el-button @click="sq_cancel">取 消</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ <!-- 选项管理对话框 -->
|
|
|
+ <el-dialog :title="`管理题目【${sq_optionDialog.question?.questionTitle}】的选项`" v-model="sq_optionDialog.visible" width="850px" append-to-body>
|
|
|
+ <div>
|
|
|
+ <el-button type="primary" icon="Plus" @click="sq_addOption" size="small" class="mb-2">新增选项</el-button>
|
|
|
+ <el-button type="success" icon="Menu" @click="sq_addDefaultOptions" size="small" class="mb-2 ml-2">默认选项</el-button>
|
|
|
+ <el-table :data="sq_optionDialog.options" border size="small">
|
|
|
+ <el-table-column label="内容" prop="optionContent" width="295">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input v-model="scope.row.optionContent" placeholder="请输入选项内容" size="small" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="分值" prop="optionScore" width="150">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input-number v-model="scope.row.optionScore" :min="0" :max="100" size="small" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="排序" prop="optionOrder" width="150">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-input-number v-model="scope.row.optionOrder" :min="0" :max="99" size="small" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="默认" prop="isDefault" width="90">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-switch v-model="scope.row.isDefault" active-value="Y" inactive-value="N" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" width="100">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button icon="Delete" type="danger" size="small" @click="sq_removeOption(scope.$index)"></el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="sq_saveOptions" :loading="sq_optionDialog.saveLoading">保存</el-button>
|
|
|
+ <el-button @click="sq_optionDialog.visible = false">关闭</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script setup name="SqSatQuestion" lang="ts">
|
|
|
+import { ref, reactive, toRefs, onMounted, getCurrentInstance } from 'vue';
|
|
|
+import { listSatQuestion, getSatQuestion, delSatQuestion, addSatQuestion, updateSatQuestion } from '@/api/hq/satQuestion';
|
|
|
+import { SatQuestionVO, SatQuestionQuery, SatQuestionForm } from '@/api/hq/satQuestion/types';
|
|
|
+import { listSatCategory, listAllSatCategory } from '@/api/hq/satCategory';
|
|
|
+import { SatCategoryVO } from '@/api/hq/satCategory/types';
|
|
|
+import { nextTick } from 'vue';
|
|
|
+import { listSatOption, addSatOption, updateSatOption, delSatOption } from '@/api/hq/satOption';
|
|
|
+
|
|
|
+// 定义类型接口
|
|
|
+interface DialogOption {
|
|
|
+ visible: boolean;
|
|
|
+ title: string;
|
|
|
+}
|
|
|
+
|
|
|
+interface PageData<T, Q> {
|
|
|
+ form: T;
|
|
|
+ queryParams: Q;
|
|
|
+ rules: any;
|
|
|
+}
|
|
|
+
|
|
|
+const { proxy: sq_proxy } = getCurrentInstance() as any;
|
|
|
+const {
|
|
|
+ sys_question_category: sq_sys_question_category,
|
|
|
+ sys_item_enable: sq_sys_item_enable,
|
|
|
+ sys_item_required: sq_sys_item_required,
|
|
|
+ sys_item_delete: sq_sys_item_delete
|
|
|
+} = toRefs<any>(sq_proxy?.useDict('sys_question_category', 'sys_item_enable', 'sys_item_required', 'sys_item_delete'));
|
|
|
+
|
|
|
+const sq_satQuestionList = ref<SatQuestionVO[]>([]);
|
|
|
+const sq_satCategoryList = ref<SatCategoryVO[]>([]);
|
|
|
+const sq_satCategoryAllList = ref<SatCategoryVO[]>([]);
|
|
|
+const sq_buttonLoading = ref(false);
|
|
|
+const sq_loading = ref(true);
|
|
|
+const sq_showSearch = ref(true);
|
|
|
+const sq_ids = ref<Array<string | number>>([]);
|
|
|
+const sq_single = ref(true);
|
|
|
+const sq_multiple = ref(true);
|
|
|
+const sq_total = ref(0);
|
|
|
+
|
|
|
+const sq_queryFormRef = ref<any>();
|
|
|
+const sq_satQuestionFormRef = ref<any>();
|
|
|
+
|
|
|
+const sq_dialog = reactive<DialogOption>({
|
|
|
+ visible: false,
|
|
|
+ title: ''
|
|
|
+});
|
|
|
+
|
|
|
+const sq_optionDialog = reactive({
|
|
|
+ visible: false,
|
|
|
+ question: null as SatQuestionVO | null,
|
|
|
+ options: [] as any[],
|
|
|
+ saveLoading: false
|
|
|
+});
|
|
|
+
|
|
|
+const sq_initFormData: SatQuestionForm = {
|
|
|
+ id: undefined,
|
|
|
+ deleted: undefined,
|
|
|
+ questionTitle: undefined,
|
|
|
+ questionContent: undefined,
|
|
|
+ categoryId: undefined,
|
|
|
+ questionType: '1',
|
|
|
+ isRequired: 1,
|
|
|
+ sortOrder: undefined,
|
|
|
+ status: '0',
|
|
|
+ remark: undefined
|
|
|
+};
|
|
|
+
|
|
|
+const sq_data = reactive<PageData<SatQuestionForm, SatQuestionQuery>>({
|
|
|
+ form: { ...sq_initFormData },
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ deleted: undefined,
|
|
|
+ questionTitle: undefined,
|
|
|
+ questionContent: undefined,
|
|
|
+ categoryId: undefined,
|
|
|
+ questionType: undefined,
|
|
|
+ isRequired: undefined,
|
|
|
+ sortOrder: undefined,
|
|
|
+ status: undefined,
|
|
|
+ params: {}
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ id: [{ required: true, message: '主键ID不能为空', trigger: 'blur' }],
|
|
|
+ questionTitle: [{ required: true, message: '题目标题不能为空', trigger: 'blur' }],
|
|
|
+ categoryId: [{ required: true, message: '所属分类不能为空', trigger: 'blur' }]
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const { queryParams: sq_queryParams, form: sq_form, rules: sq_rules } = toRefs(sq_data);
|
|
|
+
|
|
|
+/** 查询题库列表 */
|
|
|
+const sq_getList = async () => {
|
|
|
+ sq_loading.value = true;
|
|
|
+ const res = await listSatQuestion(sq_queryParams.value);
|
|
|
+ sq_satQuestionList.value = res.rows;
|
|
|
+ sq_total.value = res.total;
|
|
|
+ sq_loading.value = false;
|
|
|
+};
|
|
|
+
|
|
|
+/** 获取分类列表 */
|
|
|
+const sq_getCategoryList = async () => {
|
|
|
+ const res = await listSatCategory({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 1000,
|
|
|
+ status: '0'
|
|
|
+ });
|
|
|
+ sq_satCategoryList.value = res.rows.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
|
+};
|
|
|
+
|
|
|
+/** 获取全部分类列表(包括已删除的) */
|
|
|
+const sq_getAllCategoryList = async () => {
|
|
|
+ const res = await listAllSatCategory({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 1000
|
|
|
+ });
|
|
|
+ sq_satCategoryAllList.value = res.data.sort((a, b) => a.sortOrder - b.sortOrder);
|
|
|
+};
|
|
|
+
|
|
|
+/** 取消按钮 */
|
|
|
+const sq_cancel = () => {
|
|
|
+ sq_reset();
|
|
|
+ sq_dialog.visible = false;
|
|
|
+};
|
|
|
+
|
|
|
+/** 表单重置 */
|
|
|
+const sq_reset = () => {
|
|
|
+ sq_form.value = { ...sq_initFormData };
|
|
|
+ sq_satQuestionFormRef.value?.resetFields();
|
|
|
+};
|
|
|
+
|
|
|
+/** 搜索按钮操作 */
|
|
|
+const sq_handleQuery = () => {
|
|
|
+ sq_queryParams.value.pageNum = 1;
|
|
|
+ sq_getList();
|
|
|
+};
|
|
|
+
|
|
|
+/** 重置按钮操作 */
|
|
|
+const sq_resetQuery = () => {
|
|
|
+ sq_queryFormRef.value?.resetFields();
|
|
|
+ sq_handleQuery();
|
|
|
+};
|
|
|
+
|
|
|
+/** 多选框选中数据 */
|
|
|
+const sq_handleSelectionChange = (selection: SatQuestionVO[]) => {
|
|
|
+ sq_ids.value = selection.map((item) => item.id);
|
|
|
+ sq_single.value = selection.length != 1;
|
|
|
+ sq_multiple.value = !selection.length;
|
|
|
+};
|
|
|
+
|
|
|
+/** 新增按钮操作 */
|
|
|
+const sq_handleAdd = () => {
|
|
|
+ sq_reset();
|
|
|
+ sq_dialog.visible = true;
|
|
|
+ sq_dialog.title = '添加题库';
|
|
|
+};
|
|
|
+
|
|
|
+/** 修改按钮操作 */
|
|
|
+const sq_handleUpdate = async (row?: SatQuestionVO) => {
|
|
|
+ sq_reset();
|
|
|
+ const _id = row?.id || sq_ids.value[0];
|
|
|
+ const res = await getSatQuestion(_id);
|
|
|
+ Object.assign(sq_form.value, res.data);
|
|
|
+ sq_dialog.visible = true;
|
|
|
+ sq_dialog.title = '修改题库';
|
|
|
+};
|
|
|
+
|
|
|
+/** 提交按钮 */
|
|
|
+const sq_submitForm = () => {
|
|
|
+ sq_satQuestionFormRef.value?.validate(async (valid: boolean) => {
|
|
|
+ if (valid) {
|
|
|
+ sq_buttonLoading.value = true;
|
|
|
+ if (sq_form.value.id) {
|
|
|
+ await updateSatQuestion(sq_form.value).finally(() => (sq_buttonLoading.value = false));
|
|
|
+ } else {
|
|
|
+ await addSatQuestion(sq_form.value).finally(() => (sq_buttonLoading.value = false));
|
|
|
+ }
|
|
|
+ sq_proxy?.$modal.msgSuccess('操作成功');
|
|
|
+ sq_dialog.visible = false;
|
|
|
+ await sq_getList();
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+/** 删除按钮操作 */
|
|
|
+const sq_handleDelete = async (row?: SatQuestionVO) => {
|
|
|
+ const _ids = row?.id || sq_ids.value;
|
|
|
+
|
|
|
+ let confirmMessage = '';
|
|
|
+ if (row) {
|
|
|
+ confirmMessage = `是否确认删除题目"${row.questionTitle}"?`;
|
|
|
+ } else {
|
|
|
+ confirmMessage = `是否确认删除选中的${sq_ids.value.length}个题目?`;
|
|
|
+ }
|
|
|
+
|
|
|
+ await sq_proxy?.$modal.confirm(confirmMessage).finally(() => (sq_loading.value = false));
|
|
|
+ await delSatQuestion(_ids);
|
|
|
+ sq_proxy?.$modal.msgSuccess('删除成功');
|
|
|
+ await sq_getList();
|
|
|
+};
|
|
|
+
|
|
|
+/** 导出按钮操作 */
|
|
|
+const sq_handleExport = () => {
|
|
|
+ sq_proxy?.download(
|
|
|
+ 'hq/satQuestion/export',
|
|
|
+ {
|
|
|
+ ...sq_queryParams.value
|
|
|
+ },
|
|
|
+ `satQuestion_${new Date().getTime()}.xlsx`
|
|
|
+ );
|
|
|
+};
|
|
|
+
|
|
|
+const sq_toolbarRef = ref<HTMLElement>();
|
|
|
+const sq_searchRef = ref<HTMLElement>();
|
|
|
+
|
|
|
+const sq_handleOptionManage = async (row: SatQuestionVO) => {
|
|
|
+ sq_optionDialog.visible = true;
|
|
|
+ sq_optionDialog.question = row;
|
|
|
+
|
|
|
+ sq_proxy?.$modal.loading('正在加载选项数据...');
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await listSatOption({
|
|
|
+ questionId: row.id,
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 100
|
|
|
+ });
|
|
|
+
|
|
|
+ sq_optionDialog.options = res.rows.map((item) => ({
|
|
|
+ id: item.id,
|
|
|
+ questionId: item.questionId,
|
|
|
+ optionContent: item.optionContent,
|
|
|
+ optionScore: item.optionScore,
|
|
|
+ optionOrder: item.optionOrder,
|
|
|
+ isDefault: item.isDefault || 'N',
|
|
|
+ tenantId: item.tenantId,
|
|
|
+ createBy: item.createBy,
|
|
|
+ createTime: item.createTime,
|
|
|
+ updateBy: item.updateBy,
|
|
|
+ updateTime: item.updateTime,
|
|
|
+ deleted: item.deleted
|
|
|
+ }));
|
|
|
+
|
|
|
+ sq_optionDialog.options.sort((a, b) => a.optionOrder - b.optionOrder);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('加载选项失败:', error);
|
|
|
+ sq_optionDialog.options = [];
|
|
|
+ sq_proxy?.$modal.msgError('选项数据加载失败,请重试');
|
|
|
+ } finally {
|
|
|
+ sq_proxy?.$modal.closeLoading();
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+const sq_addOption = () => {
|
|
|
+ sq_optionDialog.options.push({
|
|
|
+ id: undefined,
|
|
|
+ questionId: sq_optionDialog.question?.id,
|
|
|
+ optionContent: '',
|
|
|
+ optionScore: 0,
|
|
|
+ optionOrder: sq_optionDialog.options.length + 1,
|
|
|
+ isDefault: 'N',
|
|
|
+ tenantId: '',
|
|
|
+ createBy: '',
|
|
|
+ createTime: '',
|
|
|
+ updateBy: '',
|
|
|
+ updateTime: '',
|
|
|
+ deleted: '0'
|
|
|
+ });
|
|
|
+ nextTick(() => {
|
|
|
+ // 可选:自动聚焦新行
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const sq_addDefaultOptions = () => {
|
|
|
+ const defaultOptions = [
|
|
|
+ {
|
|
|
+ optionContent: '非常满意',
|
|
|
+ optionScore: 5,
|
|
|
+ optionOrder: 0,
|
|
|
+ isDefault: 'Y'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ optionContent: '满意',
|
|
|
+ optionScore: 3,
|
|
|
+ optionOrder: 1,
|
|
|
+ isDefault: 'N'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ optionContent: '一般满意',
|
|
|
+ optionScore: 1,
|
|
|
+ optionOrder: 2,
|
|
|
+ isDefault: 'N'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ optionContent: '不满意',
|
|
|
+ optionScore: 0,
|
|
|
+ optionOrder: 3,
|
|
|
+ isDefault: 'N'
|
|
|
+ }
|
|
|
+ ];
|
|
|
+
|
|
|
+ defaultOptions.forEach((option) => {
|
|
|
+ sq_optionDialog.options.push({
|
|
|
+ id: undefined,
|
|
|
+ questionId: sq_optionDialog.question?.id,
|
|
|
+ optionContent: option.optionContent,
|
|
|
+ optionScore: option.optionScore,
|
|
|
+ optionOrder: option.optionOrder,
|
|
|
+ isDefault: option.isDefault,
|
|
|
+ tenantId: '',
|
|
|
+ createBy: '',
|
|
|
+ createTime: '',
|
|
|
+ updateBy: '',
|
|
|
+ updateTime: '',
|
|
|
+ deleted: '0'
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ sq_proxy?.$modal.msgSuccess('已添加默认选项');
|
|
|
+};
|
|
|
+
|
|
|
+const sq_removeOption = (index: number) => {
|
|
|
+ sq_optionDialog.options.splice(index, 1);
|
|
|
+};
|
|
|
+
|
|
|
+const sq_saveOptions = async () => {
|
|
|
+ if (!sq_optionDialog.question?.id) {
|
|
|
+ sq_proxy?.$modal.msgError('题目ID不能为空');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (sq_optionDialog.saveLoading) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ sq_optionDialog.saveLoading = true;
|
|
|
+ sq_proxy?.$modal.loading('正在保存选项数据...');
|
|
|
+
|
|
|
+ try {
|
|
|
+ const res = await listSatOption({
|
|
|
+ questionId: sq_optionDialog.question.id,
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 100
|
|
|
+ });
|
|
|
+ const existingOptions = res.rows || [];
|
|
|
+
|
|
|
+ const promises = [];
|
|
|
+
|
|
|
+ for (const option of sq_optionDialog.options) {
|
|
|
+ if (!option.optionContent || option.optionContent.trim() === '') {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ const params = {
|
|
|
+ id: option.id,
|
|
|
+ questionId: sq_optionDialog.question.id,
|
|
|
+ optionContent: option.optionContent,
|
|
|
+ optionScore: option.optionScore || 0,
|
|
|
+ optionOrder: option.optionOrder || 1,
|
|
|
+ status: '0',
|
|
|
+ isDefault: option.isDefault || 'N'
|
|
|
+ };
|
|
|
+
|
|
|
+ if (option.id) {
|
|
|
+ promises.push(updateSatOption(params));
|
|
|
+ } else {
|
|
|
+ promises.push(addSatOption(params));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const currentOptionIds = sq_optionDialog.options.filter((opt) => opt.id).map((opt) => opt.id);
|
|
|
+ const optionsToDelete = existingOptions.filter((opt) => !currentOptionIds.includes(opt.id)).map((opt) => opt.id);
|
|
|
+
|
|
|
+ if (optionsToDelete.length > 0) {
|
|
|
+ promises.push(delSatOption(optionsToDelete));
|
|
|
+ }
|
|
|
+
|
|
|
+ await Promise.all(promises);
|
|
|
+
|
|
|
+ const validOptions = sq_optionDialog.options.filter((opt) => opt.optionContent && opt.optionContent.trim() !== '');
|
|
|
+ let score = 0;
|
|
|
+
|
|
|
+ if (sq_optionDialog.question.questionType === '1') {
|
|
|
+ score = Math.max(...validOptions.map((opt) => Number(opt.optionScore) || 0));
|
|
|
+ } else if (sq_optionDialog.question.questionType === '2') {
|
|
|
+ score = validOptions.reduce((sum, opt) => sum + (Number(opt.optionScore) || 0), 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (score > 0) {
|
|
|
+ await updateSatQuestion({
|
|
|
+ id: sq_optionDialog.question.id,
|
|
|
+ categoryId: sq_optionDialog.question.categoryId,
|
|
|
+ questionType: sq_optionDialog.question.questionType,
|
|
|
+ isRequired: sq_optionDialog.question.isRequired,
|
|
|
+ sortOrder: sq_optionDialog.question.sortOrder,
|
|
|
+ status: sq_optionDialog.question.status,
|
|
|
+ remark: sq_optionDialog.question.remark,
|
|
|
+ questionTitle: sq_optionDialog.question.questionTitle,
|
|
|
+ questionContent: sq_optionDialog.question.questionContent,
|
|
|
+ score: score
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ await sq_getList();
|
|
|
+ sq_proxy?.$modal.msgSuccess('保存成功');
|
|
|
+
|
|
|
+ const currentQuestion = { ...sq_optionDialog.question };
|
|
|
+
|
|
|
+ const optRes = await listSatOption({
|
|
|
+ questionId: currentQuestion.id,
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 100
|
|
|
+ });
|
|
|
+
|
|
|
+ sq_optionDialog.options = optRes.rows.map((item) => ({
|
|
|
+ id: item.id,
|
|
|
+ questionId: item.questionId,
|
|
|
+ optionContent: item.optionContent,
|
|
|
+ optionScore: item.optionScore,
|
|
|
+ optionOrder: item.optionOrder,
|
|
|
+ isDefault: item.isDefault || 'N',
|
|
|
+ tenantId: item.tenantId,
|
|
|
+ createBy: item.createBy,
|
|
|
+ createTime: item.createTime,
|
|
|
+ updateBy: item.updateBy,
|
|
|
+ updateTime: item.updateTime,
|
|
|
+ deleted: item.deleted
|
|
|
+ }));
|
|
|
+
|
|
|
+ sq_optionDialog.options.sort((a, b) => a.optionOrder - b.optionOrder);
|
|
|
+ } catch (error) {
|
|
|
+ console.error('保存选项失败:', error);
|
|
|
+ sq_proxy?.$modal.msgError('保存失败,请重试');
|
|
|
+ } finally {
|
|
|
+ sq_proxy?.$modal.closeLoading();
|
|
|
+ sq_optionDialog.saveLoading = false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ sq_getList();
|
|
|
+ sq_getCategoryList();
|
|
|
+ sq_getAllCategoryList();
|
|
|
+});
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+/* 页面容器样式 */
|
|
|
+.page-container {
|
|
|
+ padding: 8px;
|
|
|
+}
|
|
|
+
|
|
|
+/* 表格卡片布局 */
|
|
|
+.table-card {
|
|
|
+ margin-top: 0;
|
|
|
+}
|
|
|
+
|
|
|
+.table-card :deep(.el-card__body) {
|
|
|
+ padding: 0px 20px 20px 20px !important;
|
|
|
+}
|
|
|
+
|
|
|
+/* 表格容器 */
|
|
|
+.table-container {
|
|
|
+ margin-bottom: 0;
|
|
|
+}
|
|
|
+
|
|
|
+/* 分页容器样式 */
|
|
|
+.pagination-container {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ padding: 16px 20px 0 0 !important;
|
|
|
+ background-color: #fff;
|
|
|
+ margin-top: 0px !important;
|
|
|
+}
|
|
|
+
|
|
|
+/* 移除按钮栏底部边框 */
|
|
|
+.button-card :deep(.el-card__header) {
|
|
|
+ border-bottom: none !important;
|
|
|
+}
|
|
|
+
|
|
|
+/* 文字省略样式 */
|
|
|
+.text-ellipsis {
|
|
|
+ white-space: nowrap;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ max-width: 200px;
|
|
|
+ display: inline-block;
|
|
|
+}
|
|
|
+
|
|
|
+/* 搜索按钮容器样式 */
|
|
|
+.search-btn-container {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-end;
|
|
|
+ margin-top: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.search-btn-container .el-form-item {
|
|
|
+ margin-bottom: 0 !important;
|
|
|
+}
|
|
|
+
|
|
|
+/* 左边距类 */
|
|
|
+.ml-2 {
|
|
|
+ margin-left: 8px;
|
|
|
+}
|
|
|
+</style>
|