Selaa lähdekoodia

feat(tournamentsTemplate): 更新晋级条件类型逻辑并优化表单交互

- 新增 handleQualifierTypeChange 方法,用于在类型变更时清空旧值
- 调整晋级条件值输入框的显示条件,仅当类型为"2"时展示
- 新增晋级级别下拉选项,适用于类型为"1"的情况
- 扩展 itemOptionsStructuresLevel2 数据源以支持新增选项
- 为晋级条件类型选择器添加 change 事件监听

fix(info): 移除内容样式处理相关冗余代码

- 删除不再使用的富文本内容颜色替换逻辑
- 移除已注释的内容清理及粘贴事件处理代码
- 简化 getInfo 接口返回数据的赋值过程
- 移除无效的 onUnmounted 生命周期钩子函数
fugui001 2 viikkoa sitten
vanhempi
commit
6e9b0e62d7

+ 6 - 54
src/views/system/business/info/index.vue

@@ -326,10 +326,10 @@ const handleUpdate = async (row?: InfoVO) => {
   const res = await getInfo(_id);
   iconPreviewUrl.value = res.data.imageUrl;
   // 去除content中的style属性里的color设置
-  let content = res.data.content;
-  if (content) {
+  const content = res.data.content;
+  /* if (content) {
     content = content.replace(/<p style="color: rgb\(255, 255, 255\);"/g, '<p');
-  }
+  }*/
 
   Object.assign(form.value, res.data, { content });
 
@@ -343,11 +343,11 @@ const submitForm = () => {
     if (valid) {
       const vals = form.value.content;
       console.log(vals);
-      let modifiedContent = vals;
+      /* let modifiedContent = vals;
       if (vals) {
         modifiedContent = vals.replace(/<p/g, '<p style="color: rgb(255, 255, 255);"');
       }
-      form.value.content = modifiedContent;
+      form.value.content = modifiedContent;*/
       buttonLoading.value = true;
       if (form.value.id) {
         await updateInfo(form.value).finally(() => (buttonLoading.value = false));
@@ -484,61 +484,13 @@ const quillEditorRef = ref();
   getList();
   loadCategoryOptions();
 });*/
-import { onMounted, onUnmounted } from 'vue';
-// 监听粘贴事件
-const handlePaste = (e: ClipboardEvent) => {
-  const activeElement = document.activeElement;
-
-  // 判断是否在富文本编辑器中(通过 class 或 tagName 判断)
-  // 常见富文本编辑器的编辑区通常是 contenteditable 的 div
-  const isEditor =
-    activeElement?.classList.contains('ql-editor') || // Quill
-    activeElement?.getAttribute('contenteditable') === 'true' ||
-    (activeElement?.tagName === 'DIV' && activeElement?.parentElement?.classList.contains('my-editor')); // 自定义类名
-
-  if (!isEditor) return;
-
-  e.preventDefault();
-  debugger;
-  const clipboardData = e.clipboardData || (e as any).originalEvent.clipboardData;
-  const html = clipboardData.getData('text/html');
-  const text = clipboardData.getData('text/plain');
-
-  // 创建临时元素清理 HTML
-  const tempDiv = document.createElement('div');
-  tempDiv.innerHTML = html || `<p>${text}</p>`;
-
-  // 清理所有 style 和 class
-  const walk = (node: Node) => {
-    if (node.nodeType === Node.ELEMENT_NODE) {
-      const el = node as HTMLElement;
-      el.removeAttribute('style');
-      el.removeAttribute('class');
-      el.removeAttribute('id');
-      Array.from(el.childNodes).forEach(walk);
-    }
-  };
-  Array.from(tempDiv.childNodes).forEach(walk);
-
-  const cleanHtml = tempDiv.innerHTML;
-
-  // ✅ 获取当前光标位置并插入内容(关键:使用 document.execCommand)
-  document.execCommand('insertHTML', false, cleanHtml);
-};
+import { onMounted } from 'vue';
 
 onMounted(() => {
-  // 绑定全局粘贴事件
-  //document.addEventListener('paste', handlePaste);
-
   // 其他初始化
   getList();
   loadCategoryOptions();
 });
-
-onUnmounted(() => {
-  // 移除事件,防止内存泄漏
-  document.removeEventListener('paste', handlePaste);
-});
 </script>
 <style>
 .custom-editor-content .ql-editor {

+ 20 - 3
src/views/system/business/tournamentsTemplate/index.vue

@@ -266,11 +266,17 @@
           </el-select>
         </el-form-item>
         <el-form-item label="晋级条件类型" prop="qualifierType">
-          <el-select aria-required="true" v-model="form.qualifierType" placeholder="请选择" :disabled="dialog.mode === 'view'">
+          <el-select
+            aria-required="true"
+            v-model="form.qualifierType"
+            placeholder="请选择"
+            :disabled="dialog.mode === 'view'"
+            @change="handleQualifierTypeChange"
+          >
             <el-option v-for="dict in qualifier_type" :key="dict.value" :label="dict.label" :value="dict.value"> </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="晋级条件值" prop="qualifierValue" v-if="form.qualifierType !== '0'">
+        <el-form-item label="晋级条件值" prop="qualifierValue" v-if="form.qualifierType === '2'">
           <el-input v-model="form.qualifierValue" placeholder="请输入晋级条件值" :disabled="dialog.mode === 'view'" />
         </el-form-item>
         <el-form-item label="报名时间" prop="signTime">
@@ -317,6 +323,12 @@
           </el-select>
         </el-form-item>
 
+        <el-form-item label="晋级级别" prop="qualifierValue" v-if="form.qualifierType === '1'">
+          <el-select v-model="form.qualifierValue" placeholder="选项" style="width: 200px" :disabled="dialog.mode === 'view'">
+            <el-option v-for="item in itemOptionsStructuresLevel2" :key="item.id" :label="item.label" :value="item.id" />
+          </el-select>
+        </el-form-item>
+
         <el-form-item label="起始记分牌数量" prop="startingChips">
           <el-input v-model="form.startingChips" placeholder="请输入起始记分牌数量" :disabled="dialog.mode === 'view'" />
         </el-form-item>
@@ -561,7 +573,7 @@ const loadItemStructuresOptions = async () => {
 
 // 下拉选项数据
 const itemOptionsStructuresLevel = ref<{ id: number; label: string }[]>([]);
-
+const itemOptionsStructuresLevel2 = ref<{ id: number; label: string }[]>([]);
 // 加载报名条件选项
 const handleBlindStructureChange = async (value: number) => {
   //data.form.lateRegistrationLevel = null;
@@ -579,6 +591,7 @@ const handleBlindStructureChange = async (value: number) => {
         });
       }
       itemOptionsStructuresLevel.value = list;
+      itemOptionsStructuresLevel2.value = list;
       // 判断当前选择的 lateRegistrationLevel 是否在新列表中
       const currentLevel = data.form.lateRegistrationLevel;
       if (currentLevel && !list.some((item) => item.id === currentLevel)) {
@@ -1288,6 +1301,10 @@ const handleSelectVisibleChange = async (visible: boolean) => {
     await remoteMethod('');
   }
 };
+const handleQualifierTypeChange = (value: string) => {
+  // Clear the qualifierValue when qualifierType changes
+  form.value.qualifierValue = null;
+};
 </script>
 <style scoped>
 .more-rewards {