Browse Source

编辑保存按钮切换

xtf 10 months ago
parent
commit
f849361c80
3 changed files with 38 additions and 2 deletions
  1. 8 0
      src/css/qcScore.css
  2. 9 1
      src/css/qcScore.less
  3. 21 1
      src/js/qcScore.js

+ 8 - 0
src/css/qcScore.css

@@ -1871,3 +1871,11 @@ input.canEditDept {
   padding: 7px 26px;
   margin-right: 20px;
 }
+.save{
+  width: 55px;
+  height: 26px;
+  color: #fff;
+  background: #00A1FF;
+  border-radius: 4px;
+  margin-right: 10px;
+}

+ 9 - 1
src/css/qcScore.less

@@ -1083,4 +1083,12 @@
   border-radius: 4px;
   padding: 7px 26px;
   margin-right: 20px;
-}
+}
+.save{
+  width: 55px;
+  height: 26px;
+  color: #fff;
+  background: #00A1FF;
+  border-radius: 4px;
+  margin-right: 10px;
+}

+ 21 - 1
src/js/qcScore.js

@@ -974,7 +974,7 @@ $(function () {
     const module = global_modules[mid].moduleDetail;
     const key = global_modules[mid].modeName.replace(/[^\u4e00-\u9fa5|a-zA-Z0-9]+/g, '');
     let hml = '<div class="content-item" code="' + key + '">' +
-      '<h2 class="title">' + global_modules[mid].modeName + '(' + mid + ')</h2>' +
+      '<h2 class="title">' +'<button class="save">编辑</button>'+ global_modules[mid].modeName + '(' + mid + ')</h2>' +
       (n > 1 ? '<div class="container">' : '<div class="container content-hts">');
 
 
@@ -1121,6 +1121,26 @@ $(function () {
       }
     });
   }
+  var isEditing = false;
+  $('p, .embed-table .table-1 td, .opera-table td,.embed-table .table-2 td').attr('contenteditable', isEditing);
+  $("body").on("click", ".save", function () {
+    isEditing = !isEditing; // 切换状态
+    if (isEditing) {
+      $(this).text('保存');
+    } else {
+      $(this).text('编辑');
+      // let state = saveOrUpdate()
+      // if (state === true) {
+      //   console.log("保存成功");
+      // } else {
+      //   console.log("保存失败");
+      // }
+
+
+
+    }
+    $('p, .embed-table .table-1 td, .opera-table td,.embed-table .table-2 td').attr('contenteditable', isEditing);
+  });
 
 });