Ver código fonte

修改勾选删除

yangg 5 meses atrás
pai
commit
035ff2720e

+ 3 - 3
ui/.env.development

@@ -5,9 +5,9 @@ VUE_APP_TITLE = GQY管理系统
 ENV = 'development'
 
 # GQY管理系统/开发环境
-#线上:http://120.46.190.49:8885
-#线下:http://192.168.1.102:8885
-VUE_APP_BASE_API = 'http://192.168.66.163:8885'
+#线上:http://60.204.236.53:8885
+#线下:http://192.168.66.163:8885
+VUE_APP_BASE_API = 'http://60.204.236.53:8885'
 
 
 # 路由懒加载

+ 44 - 40
ui/src/views/system/document/com/editor.vue

@@ -183,59 +183,63 @@ export default {
   watch: {
     coms: {
       handler(val) {
-        
         // 如果正在保存或没有值,则跳过处理
         if (this.isSaving || !val || !Array.isArray(val)) return;
 
         try {
-          // 检查是否需要更新
-          const needsUpdate = val.some((item, index) => {
-            const currentCom = this.comList[index];
-            if (!currentCom) return true;
-            
-            // 比较关键属性是否发生变化
-            return (
-              item.content !== currentCom.content ||
-              item.dcb_nr !== currentCom.dcb_nr ||
-              JSON.stringify(item.attrs) !== JSON.stringify(currentCom.attrs) ||
-              JSON.stringify(item.dcb_attrs) !== JSON.stringify(currentCom.dcb_attrs)||
-              item.isEdit!==currentCom.isEdit||
-              item!==currentCom
-            );
-          });
+          // 检查数组长度变化或内容更新
+          const needsUpdate = 
+            val.length !== this.comList.length || // 检查长度变化
+            val.some((item, index) => {
+              const currentCom = this.comList[index];
+              if (!currentCom) return true;
+              
+              // 比较关键属性是否发生变化
+              return (
+                item.content !== currentCom.content ||
+                item.dcb_nr !== currentCom.dcb_nr ||
+                JSON.stringify(item.attrs) !== JSON.stringify(currentCom.attrs) ||
+                JSON.stringify(item.dcb_attrs) !== JSON.stringify(currentCom.dcb_attrs) ||
+                item.isEdit !== currentCom.isEdit ||
+                item !== currentCom
+              );
+            });
 
           // 如果不需要更新,直接返回
           if (!needsUpdate) return;
+          // 处理数据,确保属性正确转换
+          const processedComs = val.map((item) => ({
+            ...item,
+            attrs: Array.isArray(item.attrs) ? item.attrs : [],
+            dcb_attrs: Array.isArray(item.dcb_attrs) 
+              ? item.dcb_attrs 
+              : (typeof item.dcb_attrs === 'string' 
+                  ? JSON.parse(item.dcb_attrs || '[]') 
+                  : []),
+            content: item.content || item.dcb_nr || '',
+            dcb_nr: item.content || item.dcb_nr || '',
+            type: item.dcb_type || item.type,
+            name: item.dcb_name || item.name,
+          }));
 
-          // 处理拖拽数据,确保属性正确转换
-          const processedComs = val.map((item) => {
-            // 首先创建基础对象
-            return {
-              ...item,
-              // 确保 attrs 和 dcb_attrs 都是数组
-              attrs: Array.isArray(item.attrs) ? item.attrs : [],
-              dcb_attrs: Array.isArray(item.dcb_attrs) 
-                ? item.dcb_attrs 
-                : (typeof item.dcb_attrs === 'string' 
-                    ? JSON.parse(item.dcb_attrs || '[]') 
-                    : []),
-              // 同步最新内容,优先使用当前显示的内容
-              content: item.content || item.dcb_nr || '',
-              dcb_nr: item.content || item.dcb_nr || '',
-              // 确保 type 使用 dcb_type
-              type: item.dcb_type || item.type,
-              // 确保 name 使用 dcb_name
-              name: item.dcb_name || item.name,
-            };
-          });
-          console.log("comList:",this.comList);
           // 使用 Vue.set 更新整个数组
           this.$set(this, 'comList', processedComs);
-          // 仅在数据确实发生变化时才触发父组件更新
+          
+          // 触发父组件更新
           this.$emit("onSetComs", this.comList);
+          
+          // 如果长度减少,可能需要更新其他相关状态
+          if (val.length < this.comList.length) {
+            this.$nextTick(() => {
+              // 更新目录序号
+              this.updateDirectoryNumbers();
+              // 触发重建
+              this.$emit("onRebuild", this.comList);
+            });
+          }
+
         } catch (error) {
           console.error('处理组件数据时出错:', error);
-          // 确保即使出错也有一个有效的数组
           if (!Array.isArray(this.comList)) {
             this.$set(this, 'comList', Array.isArray(val) ? val : []);
           }

+ 35 - 18
ui/src/views/system/document/create.vue

@@ -661,7 +661,7 @@
                   <el-button
                     type="text"
                     size="mini"
-                    @click="onRemove(index)"
+                    @click="onRemoveMdel(index)"
                   >
                     <i class="el-icon-delete"></i> 删除
                   </el-button>
@@ -2930,12 +2930,12 @@ export default {
         this.coms.push(newComponent); */
       } else {
         // 如果取消选中,从组件列表中移除
-        const index = this.coms.findIndex(
+       /*  const index = this.coms.findIndex(
           (com) => com.dcb_id === template.dcb_id
         );
         if (index !== -1) {
           this.coms.splice(index, 1);
-        }
+        } */
       }
 
       // 同步其他分类中相同模板的选中状态
@@ -3461,23 +3461,40 @@ export default {
     },
 
     // 删除模块
-    onRemove(index) {
-      console.log(index);
-      this.$confirm("此操作将删除该模块, 是否继续?", "提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning",
-      })
-        .then(() => {
-          this.coms.splice(index, 1);
-          this.$emit("onRebuild", this.coms);
-        })
-        .catch(() => {
-          this.$message({
-            type: "info",
-            message: "已取消删除",
+    onRemoveMdel(index) {
+      const removedComponent = this.coms[index];
+      
+      this.$confirm('确认删除该模块?', '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        // 从组件数组中移除
+        this.coms.splice(index, 1);
+        
+        // 如果删除的组件来自模板,更新对应模板的选中状态
+        if (removedComponent.dcb_id) {
+          // 遍历所有分类查找对应的模板
+          this.categoryList.forEach(category => {
+            const template = (category.templates || []).find(t => t.dcb_id === removedComponent.dcb_id);
+            if (template) {
+              // 取消模板的选中状态
+              this.updateTemplateSelection(template, false);
+              template.selected = false;
+            }
           });
+        }
+        
+        this.$message({
+          type: 'success',
+          message: '删除成功!'
         });
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '已取消删除'
+        });
+      });
     },
 
     // 过滤属性