MaiXinRong 8 часов назад
Родитель
Сommit
85ba9f8d7e
2 измененных файлов с 24 добавлено и 12 удалено
  1. 22 10
      app/public/js/shares/ai_trans.js
  2. 2 2
      app/view/shares/ai_trans.ejs

+ 22 - 10
app/public/js/shares/ai_trans.js

@@ -141,15 +141,15 @@ const AITrans = function() {
         $('#ai-trans-grid').modal('show');
     };
 
-    document.getElementById('ai-trans-file-add').addEventListener('dragenter', function(e) {
-        e.preventDefault();
-        this.style.backgroundColor = '#f0f0f0';
-    });
-    document.getElementById('ai-trans-file-add').addEventListener('dragleave', function(e) {
-        if (e.relatedTarget !== this) {
-            this.style.backgroundColor = '';
-        }
-    });
+    // document.getElementById('ai-trans-file-add').addEventListener('dragenter', function(e) {
+    //     e.preventDefault();
+    //     this.style.backgroundColor = '#f0f0f0';
+    // });
+    // document.getElementById('ai-trans-file-add').addEventListener('dragleave', function(e) {
+    //     if (e.relatedTarget !== this) {
+    //         this.style.backgroundColor = '';
+    //     }
+    // });
     document.getElementById('ai-trans-file-add').addEventListener('dragover', function(e) {
         e.preventDefault();
         e.dataTransfer.dropEffect = 'copy';
@@ -176,11 +176,23 @@ const AITrans = function() {
 
         transResultObj.uploadFile(files);
     });
+    $('#ai-trans-file-add').click(function() {
+        if (transResultObj.rela_node.aiRelaFile && transResultObj.rela_node.aiRelaFile.length >= 3) {
+            toastr.warning('保存的图片超过限制,请先删除旧图片后再操作');
+            return;
+        }
+
+        const e = new MouseEvent('click', { view: window, bubbles: true, cancelable: true });
+        document.getElementById('ai-trans-file').dispatchEvent(e);
+    });
+    $('#ai-trans-file').change(function() {
+        transResultObj.uploadFile(this.files);
+    });
     $('body').on('click', '[name=ai-his-file]', function() {
         transResultObj.selectFile(this.getAttribute('fid'));
     });
     $('#ai-trans').on('paste', transResultObj.pasteImage);
-    $('body').on('click', '.ai-del-btn', function() {
+    $('body').on('click', '.ai-del-btn', function(e) {
         const fid = $(this).parent().attr('fid');
         transResultObj.deleteFile(fid);
         e.stopPropagation();

+ 2 - 2
app/view/shares/ai_trans.ejs

@@ -95,7 +95,7 @@
                                 <div class="card-body">
                                     <div class="d-flex p-1" >
                                         <!--<i class="fa fa-plus fa-3x text-black-50"></i>-->
-                                        <span class="text-black-50 p-1 d-flex" style="font-size: 60px; width: 50px; height: 50px; line-height: 30px">+</span>
+                                        <span class="text-black-50 p-1 d-flex" style="font-size: 60px; width: 50px; height: 50px; line-height: 30px; cursor: default;">+</span>
                                     </div>
                                 </div>
                             </div>
@@ -118,7 +118,7 @@
                 <!--</div>-->
             </div>
             <div class="modal-footer">
-                <input type="hidden" class="form-control-file" id="ai-trans-file" name="file">
+                <input type="file" class="form-control-file" id="ai-trans-file" name="file" style="display: none">
                 <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">关闭</button>
                 <a href="javascript: void(0);" class="btn btn-sm btn-primary" id="ai-trans-ok">确定</a>
             </div>