| | |
| | | </div> |
| | | </div> |
| | | <div class="header-right"> |
| | | <!-- 异常选项状态 --> |
| | | <div |
| | | class="option-status" |
| | | v-if=" |
| | | templateForm.templateType != 3 && |
| | | templateForm.templateType != 4 |
| | | " |
| | | > |
| | | <el-tooltip |
| | | :content=" |
| | | checkHasAbnormalOptions(question) |
| | | ? '已有异常选项' |
| | | : '暂无异常选项' |
| | | " |
| | | placement="top" |
| | | > |
| | | <el-tag |
| | | :type=" |
| | | checkHasAbnormalOptions(question) ? 'success' : 'danger' |
| | | " |
| | | size="small" |
| | | class="status-tag" |
| | | > |
| | | <i |
| | | :class=" |
| | | checkHasAbnormalOptions(question) |
| | | ? 'el-icon-success' |
| | | : 'el-icon-warning' |
| | | " |
| | | ></i> |
| | | {{ |
| | | checkHasAbnormalOptions(question) |
| | | ? "异常选项已配置" |
| | | : "无异常选项" |
| | | }} |
| | | </el-tag> |
| | | </el-tooltip> |
| | | </div> |
| | | |
| | | <el-button |
| | | type="text" |
| | | icon="el-icon-view" |
| | |
| | | size="small" |
| | | > |
| | | 预览 |
| | | </el-button> |
| | | |
| | | <!-- 添加配置选项按钮 --> |
| | | <el-button |
| | | v-if=" |
| | | templateForm.templateType != 3 && |
| | | templateForm.templateType != 4 |
| | | " |
| | | type="text" |
| | | icon="el-icon-setting" |
| | | @click="openOptionDialog(question)" |
| | | size="small" |
| | | > |
| | | 配置选项 |
| | | </el-button> |
| | | </div> |
| | | </div> |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <!-- 选项配置对话框 --> |
| | | <el-dialog |
| | | title="选项异常状态配置" |
| | | :visible.sync="optionDialogVisible" |
| | | width="700px" |
| | | center |
| | | :close-on-click-modal="false" |
| | | > |
| | | <div v-if="editingQuestion" class="option-config-wrapper"> |
| | | <div class="dialog-header"> |
| | | <h4>{{ editingQuestion.scriptTopic || '无主题' }}</h4> |
| | | <p class="dialog-subtitle">{{ editingQuestion.scriptContent }}</p> |
| | | </div> |
| | | |
| | | <div class="option-list"> |
| | | <el-alert |
| | | v-if="!currentOptions.some(opt => opt.isabnormal === 1)" |
| | | title="请至少设置一个异常选项(标记为异常)" |
| | | type="warning" |
| | | :closable="false" |
| | | show-icon |
| | | style="margin-bottom: 20px;" |
| | | /> |
| | | |
| | | <div v-for="(option, index) in currentOptions" :key="index" class="option-item"> |
| | | <el-form |
| | | :model="option" |
| | | :rules="optionRules" |
| | | ref="optionForm" |
| | | size="small" |
| | | class="option-form" |
| | | > |
| | | <el-row :gutter="12" align="middle"> |
| | | <el-col :span="2"> |
| | | <div class="option-index">#{{ index + 1 }}</div> |
| | | </el-col> |
| | | |
| | | <el-col :span="12"> |
| | | <el-form-item prop="targetvalue"> |
| | | <el-input |
| | | v-model="option.targetvalue" |
| | | placeholder="请输入选项内容" |
| | | clearable |
| | | maxlength="200" |
| | | show-word-limit |
| | | /> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="6"> |
| | | <el-form-item prop="isabnormal"> |
| | | <el-select |
| | | v-model="option.isabnormal" |
| | | placeholder="选择状态" |
| | | style="width: 100%" |
| | | > |
| | | <el-option |
| | | v-for="status in abnormalOptions" |
| | | :key="status.value" |
| | | :label="status.label" |
| | | :value="status.value" |
| | | > |
| | | <el-tag :type="status.type" size="small">{{ status.label }}</el-tag> |
| | | </el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | </el-col> |
| | | |
| | | <el-col :span="4"> |
| | | <el-button |
| | | type="danger" |
| | | icon="el-icon-delete" |
| | | @click="removeOption(index)" |
| | | size="small" |
| | | circle |
| | | plain |
| | | /> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form> |
| | | </div> |
| | | |
| | | <!-- <el-button |
| | | type="primary" |
| | | icon="el-icon-plus" |
| | | @click="addNewOption" |
| | | size="small" |
| | | plain |
| | | style="width: 100%; margin-top: 10px;" |
| | | > |
| | | 添加选项 |
| | | </el-button> --> |
| | | </div> |
| | | </div> |
| | | |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="optionDialogVisible = false">取消</el-button> |
| | | <el-button type="primary" @click="saveOptions" :loading="savingOptions"> |
| | | 保存配置 |
| | | </el-button> |
| | | </span> |
| | | </el-dialog> |
| | | <!-- 题目预览对话框 --> |
| | | <el-dialog |
| | | title="题目预览" |
| | |
| | | { required: true, message: "请选择模板类型", trigger: "change" }, |
| | | ], |
| | | }, |
| | | // 选项管理相关 |
| | | optionDialogVisible: false, |
| | | currentOptions: [], |
| | | editingQuestion: null, |
| | | optionRules: { |
| | | targetvalue: [ |
| | | { required: true, message: "请输入选项内容", trigger: "blur" }, |
| | | ], |
| | | isabnormal: [ |
| | | { required: true, message: "请选择异常状态", trigger: "change" }, |
| | | ], |
| | | }, |
| | | |
| | | // 异常状态选项 |
| | | abnormalOptions: [ |
| | | { label: "正常", value: 0, type: "success" }, |
| | | { label: "异常", value: 1, type: "danger" }, |
| | | { label: "警告", value: 2, type: "warning" }, |
| | | ], |
| | | // 模板选项 |
| | | questionnaireTemplates: [], // 问卷模板列表 |
| | | followupTemplates: [], // 语音模板列表 |
| | |
| | | changedCount: 0, |
| | | |
| | | // 满意度分类ID |
| | | satisfactionCategoryIds: ["404", "405", "406"], |
| | | |
| | | satisfactionCategoryIds: ["404", "405", "406", "10039", "10041", "10042"], |
| | | questionnaireCategorys: [], |
| | | voiceCategories: [], |
| | | // 表单验证规则 |
| | | configRules: { |
| | | responsibilityDept: [ |
| | |
| | | |
| | | // 满意度题目数量 |
| | | satisfactionQuestionsCount() { |
| | | return this.questionList.filter((q) => |
| | | this.satisfactionCategoryIds.includes(q.categoryid?.toString()) |
| | | ).length; |
| | | if (this.templateForm.templateType === 1) { |
| | | return this.questionList.filter((q) => |
| | | this.questionnaireCategorys.includes(q.categoryid) |
| | | ).length; |
| | | } else if (this.templateForm.templateType === 2) { |
| | | return this.questionList.filter((q) => |
| | | this.voiceCategories.includes(q.scriptAssortid) |
| | | ).length; |
| | | } |
| | | }, |
| | | // 检查题目是否有异常选项 |
| | | hasAbnormalOption(question) { |
| | | return (question) => { |
| | | if (!question) return false; |
| | | |
| | | // 问卷模板 |
| | | if (this.templateForm.templateType === 1) { |
| | | const options = question.svyLibTemplateTargetoptions || []; |
| | | return options.some((opt) => opt.isabnormal === 1); |
| | | } |
| | | // 语音模板 |
| | | else if (this.templateForm.templateType === 2) { |
| | | const options = question.ivrLibaScriptTargetoptionList || []; |
| | | return options.some((opt) => opt.isabnormal === 1); |
| | | } |
| | | |
| | | return false; |
| | | }; |
| | | }, |
| | | // 筛选后的题目列表 |
| | | filteredQuestionList() { |
| | | let filtered = this.questionList; |
| | | console.log(this.questionnaireCategorys); |
| | | |
| | | // 筛选满意度题目 |
| | | filtered = filtered.filter((q) => |
| | | this.satisfactionCategoryIds.includes(q.categoryid?.toString()) |
| | | ); |
| | | if (this.templateForm.templateType === 1) { |
| | | filtered = filtered.filter((q) => |
| | | this.questionnaireCategorys.includes(q.categoryid) |
| | | ); |
| | | } else if (this.templateForm.templateType === 2) { |
| | | filtered = filtered.filter((q) => |
| | | this.voiceCategories.includes(q.scriptAssortid) |
| | | ); |
| | | } |
| | | |
| | | // 应用搜索条件 |
| | | if (this.queryParams.scriptTopic) { |
| | |
| | | }, |
| | | }, |
| | | created() { |
| | | if (store.getters.satisfactionCategories) { |
| | | this.questionnaireCategorys = |
| | | store.getters.satisfactionCategories.questionnaireCategorys.map( |
| | | (item) => item.categoryid |
| | | ); |
| | | this.voiceCategories = |
| | | store.getters.satisfactionCategories.voiceCategories.map( |
| | | (item) => item.categoryid |
| | | ); |
| | | } |
| | | this.getDeptOptions(); |
| | | this.loadAllTemplates(); |
| | | }, |
| | |
| | | questionCount: 0, |
| | | }; |
| | | } |
| | | // 加载模板详情数据 |
| | | // 加载模板详情数据 |
| | | this.templateLoading = true; |
| | | this.loading = true; |
| | | this.questionList = []; |
| | |
| | | /** 配置变更处理 */ |
| | | handleConfigChange(question) { |
| | | this.$nextTick(() => { |
| | | const index = this.questionList.findIndex((q) => q.id === question.id); |
| | | const index = this.filteredQuestionList.findIndex( |
| | | (q) => q.id === question.id |
| | | ); |
| | | if (index !== -1) { |
| | | const formRef = this.$refs.configForm && this.$refs.configForm[index]; |
| | | if (formRef) { |
| | |
| | | async saveSingleConfig(question) { |
| | | if (!question.hasChanges) return; |
| | | |
| | | const index = this.questionList.findIndex((q) => q.id === question.id); |
| | | const index = this.filteredQuestionList.findIndex( |
| | | (q) => q.id === question.id |
| | | ); |
| | | console.log(index, "filteredQuestionList"); |
| | | |
| | | if (index === -1) return; |
| | | |
| | | const formRef = this.$refs.configForm && this.$refs.configForm[index]; |
| | |
| | | }, |
| | | |
| | | /** 重置单个题目配置 */ |
| | | /** 重置单个题目配置 */ |
| | | resetSingleConfig(question) { |
| | | this.$confirm("确定要重置当前题目的配置吗?", "提示", { |
| | | confirmButtonText: "确定", |
| | |
| | | this.previewAnswer = ""; |
| | | this.previewVisible = true; |
| | | }, |
| | | /** 检查题目是否有异常选项 */ |
| | | checkHasAbnormalOptions(question) { |
| | | if (this.templateForm.templateType === 1) { |
| | | return (question.svyLibTemplateTargetoptions || []).some( |
| | | (opt) => opt.isabnormal === 1 |
| | | ); |
| | | } else if (this.templateForm.templateType === 2) { |
| | | return (question.ivrLibaScriptTargetoptionList || []).some( |
| | | (opt) => opt.isabnormal === 1 |
| | | ); |
| | | } |
| | | return false; |
| | | }, |
| | | |
| | | /** 打开选项管理对话框 */ |
| | | openOptionDialog(question) { |
| | | this.editingQuestion = question; |
| | | |
| | | // 复制选项数据 |
| | | if (this.templateForm.templateType === 1) { |
| | | this.currentOptions = JSON.parse( |
| | | JSON.stringify(question.svyLibTemplateTargetoptions || []) |
| | | ).map((opt) => ({ |
| | | ...opt, |
| | | id: opt.id, |
| | | targetvalue: opt.optioncontent || "", |
| | | isabnormal: opt.isabnormal || 0, |
| | | })); |
| | | } else if (this.templateForm.templateType === 2) { |
| | | this.currentOptions = JSON.parse( |
| | | JSON.stringify(question.ivrLibaScriptTargetoptionList || []) |
| | | ).map((opt) => ({ |
| | | ...opt, |
| | | targetvalue: opt.targetvalue || "", |
| | | isabnormal: opt.isabnormal || 0, |
| | | })); |
| | | } |
| | | |
| | | this.optionDialogVisible = true; |
| | | }, |
| | | |
| | | /** 添加新选项 */ |
| | | addNewOption() { |
| | | this.currentOptions.push({ |
| | | id: Date.now(), // 临时ID |
| | | targetvalue: "", |
| | | isabnormal: 0, |
| | | isNew: true, |
| | | }); |
| | | }, |
| | | |
| | | /** 删除选项 */ |
| | | removeOption(index) { |
| | | this.currentOptions.splice(index, 1); |
| | | }, |
| | | |
| | | /** 保存选项配置 */ |
| | | async saveOptions() { |
| | | try { |
| | | // 验证必填项 |
| | | for (const option of this.currentOptions) { |
| | | if (!option.targetvalue || option.targetvalue.trim() === "") { |
| | | this.$message.warning("请填写所有选项内容"); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | // 检查是否有异常选项 |
| | | const hasAbnormal = this.currentOptions.some( |
| | | (opt) => opt.isabnormal === 1 |
| | | ); |
| | | |
| | | if (!hasAbnormal) { |
| | | this.$message.warning("请至少设置一个异常选项(isabnormal=1)"); |
| | | return; |
| | | } |
| | | |
| | | // 保存逻辑 - 更新题目对象的选项数据 |
| | | if (this.templateForm.templateType === 1) { |
| | | this.editingQuestion.svyLibTemplateTargetoptions = |
| | | this.currentOptions.map((opt) => ({ |
| | | ...opt, |
| | | optioncontent: opt.targetvalue, |
| | | isabnormal: opt.isabnormal, |
| | | })); |
| | | } else if (this.templateForm.templateType === 2) { |
| | | this.editingQuestion.ivrLibaScriptTargetoptionList = |
| | | this.currentOptions; |
| | | } |
| | | |
| | | // 触发配置变更检查 |
| | | this.handleConfigChange(this.editingQuestion); |
| | | |
| | | this.$message.success("选项配置保存成功"); |
| | | this.optionDialogVisible = false; |
| | | } catch (error) { |
| | | console.error("保存选项失败:", error); |
| | | this.$message.error("保存选项失败"); |
| | | } |
| | | }, |
| | | |
| | | /** 修改保存单个题目配置方法,添加异常选项检查 */ |
| | | async saveSingleConfig(question) { |
| | | // 检查是否有异常选项 |
| | | if (!this.checkHasAbnormalOptions(question)) { |
| | | this.$confirm("该题目没有设置异常选项,是否先配置选项?", "提示", { |
| | | confirmButtonText: "去配置", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | this.openOptionDialog(question); |
| | | }) |
| | | .catch(() => {}); |
| | | return; |
| | | } |
| | | |
| | | // 原有的保存逻辑... |
| | | if (!question.hasChanges) return; |
| | | |
| | | const index = this.filteredQuestionList.findIndex( |
| | | (q) => q.id === question.id |
| | | ); |
| | | |
| | | if (index === -1) return; |
| | | |
| | | const formRef = this.$refs.configForm && this.$refs.configForm[index]; |
| | | if (!formRef) return; |
| | | |
| | | const valid = await formRef.validate(); |
| | | if (!valid) { |
| | | this.$message.warning("请先完成必填项"); |
| | | return; |
| | | } |
| | | |
| | | // 继续原有的保存逻辑... |
| | | question.saving = true; |
| | | question.saveStatus = null; |
| | | |
| | | try { |
| | | // ... 原有的保存逻辑不变 |
| | | } catch (error) { |
| | | // ... 错误处理不变 |
| | | } finally { |
| | | question.saving = false; |
| | | } |
| | | }, |
| | | |
| | | /** 批量保存时也要检查 */ |
| | | async handleBatchSave() { |
| | | if (!this.hasChanges || this.batchSaving) return; |
| | | |
| | | // 检查所有有变更的题目是否都有异常选项 |
| | | const changedQuestions = this.questionList.filter((q) => q.hasChanges); |
| | | const questionsWithoutAbnormal = changedQuestions.filter( |
| | | (q) => !this.checkHasAbnormalOptions(q) |
| | | ); |
| | | |
| | | if (questionsWithoutAbnormal.length > 0) { |
| | | this.$confirm( |
| | | `有 ${questionsWithoutAbnormal.length} 个题目没有设置异常选项,请先配置选项。是否继续?`, |
| | | "提示", |
| | | { |
| | | confirmButtonText: "继续", |
| | | cancelButtonText: "去配置", |
| | | type: "warning", |
| | | } |
| | | ) |
| | | .then(() => { |
| | | // 继续执行批量保存 |
| | | this.executeBatchSave(changedQuestions); |
| | | }) |
| | | .catch(() => { |
| | | // 可以在这里跳转到第一个没有异常选项的题目 |
| | | if (questionsWithoutAbnormal.length > 0) { |
| | | this.openOptionDialog(questionsWithoutAbnormal[0]); |
| | | } |
| | | }); |
| | | } else { |
| | | this.executeBatchSave(changedQuestions); |
| | | } |
| | | }, |
| | | |
| | | /** 执行批量保存 */ |
| | | async executeBatchSave(changedQuestions) { |
| | | this.$confirm("确定要保存所有修改过的配置吗?", "批量保存", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(async () => { |
| | | this.batchSaving = true; |
| | | |
| | | const results = []; |
| | | for (const question of changedQuestions) { |
| | | try { |
| | | // 这里调用修改后的saveSingleConfig方法 |
| | | await this.saveSingleConfig(question); |
| | | results.push({ |
| | | id: question.id, |
| | | success: |
| | | !question.hasChanges && |
| | | question.saveStatus?.type === "success", |
| | | }); |
| | | } catch (error) { |
| | | results.push({ |
| | | id: question.id, |
| | | success: false, |
| | | }); |
| | | } |
| | | } |
| | | |
| | | this.batchSaving = false; |
| | | // ... 后续处理不变 |
| | | }) |
| | | .catch(() => { |
| | | this.batchSaving = false; |
| | | }); |
| | | }, |
| | | |
| | | /** 获取异常选项统计 */ |
| | | getAbnormalStats(question) { |
| | | if (this.templateForm.templateType === 1) { |
| | | const options = question.svyLibTemplateTargetoptions || []; |
| | | return { |
| | | total: options.length, |
| | | abnormal: options.filter((opt) => opt.isabnormal === 1).length, |
| | | warning: options.filter((opt) => opt.isabnormal === 2).length, |
| | | normal: options.filter((opt) => opt.isabnormal === 0).length, |
| | | }; |
| | | } else if (this.templateForm.templateType === 2) { |
| | | const options = question.ivrLibaScriptTargetoptionList || []; |
| | | return { |
| | | total: options.length, |
| | | abnormal: options.filter((opt) => opt.isabnormal === 1).length, |
| | | warning: options.filter((opt) => opt.isabnormal === 2).length, |
| | | normal: options.filter((opt) => opt.isabnormal === 0).length, |
| | | }; |
| | | } |
| | | return { total: 0, abnormal: 0, warning: 0, normal: 0 }; |
| | | }, |
| | | /** 搜索 */ |
| | | handleQuery() { |
| | | // 仅筛选显示,不需要重新加载 |
| | |
| | | } |
| | | |
| | | .header-right { |
| | | flex-shrink: 0; |
| | | display: flex; |
| | | flex-direction: column; |
| | | align-items: flex-end; |
| | | gap: 8px; |
| | | |
| | | .option-status { |
| | | .status-tag { |
| | | cursor: default; |
| | | |
| | | i { |
| | | margin-right: 4px; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | } |
| | | .option-config-wrapper { |
| | | .dialog-header { |
| | | margin-bottom: 20px; |
| | | padding-bottom: 15px; |
| | | border-bottom: 1px solid #ebeef5; |
| | | |
| | | h4 { |
| | | margin: 0 0 8px 0; |
| | | color: #303133; |
| | | font-size: 16px; |
| | | font-weight: 600; |
| | | } |
| | | |
| | | .dialog-subtitle { |
| | | margin: 0; |
| | | color: #606266; |
| | | font-size: 13px; |
| | | line-height: 1.4; |
| | | } |
| | | } |
| | | |
| | | .option-list { |
| | | .option-item { |
| | | margin-bottom: 12px; |
| | | padding: 12px; |
| | | background: #f8f9fa; |
| | | border-radius: 4px; |
| | | border: 1px solid #ebeef5; |
| | | |
| | | &:hover { |
| | | border-color: #dcdfe6; |
| | | } |
| | | |
| | | .option-form { |
| | | .option-index { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | height: 100%; |
| | | color: #909399; |
| | | font-weight: 500; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | @media (max-width: 768px) { |
| | | .satisfaction-exception-config { |
| | | padding: 12px; |