tangning 2 лет назад
Родитель
Сommit
599f499a28
1 измененных файлов с 18 добавлено и 1 удалено
  1. 18 1
      src/views/empower/logListModal.vue

+ 18 - 1
src/views/empower/logListModal.vue

@@ -6,7 +6,13 @@
     :width="800"
     @visible-change="handleVisibleChange"
   >
-    <BasicTable @register="registerSubtable"></BasicTable>
+    <BasicTable @register="registerSubtable">
+      <template #copy="{ text }">
+        <a @click="handleCopy(text)">
+          {{ text }}
+        </a>
+      </template>
+    </BasicTable>
   </BasicModal>
 </template>
 <script lang="ts">
@@ -59,6 +65,7 @@
         {
           title: '更换Key',
           dataIndex: 'updateAuthorizeKey',
+          slots: { customRender: 'copy' },
           width: 150,
         },
         {
@@ -112,6 +119,15 @@
         closeModal();
         emit('update');
       };
+      function handleCopy(str: string) {
+        let save = function (e) {
+          e.clipboardData.setData('text/plain', str);
+          e.preventDefault(); //阻止默认行为
+        };
+        document.addEventListener('copy', save); //添加一个copy事件
+        document.execCommand('copy'); //执行copy方法
+        createMessage.success('复制成功');
+      }
       function handleVisibleChange(v) {
         v && props.userData && nextTick(() => onDataReceive(props.userData));
       }
@@ -121,6 +137,7 @@
         fileFlow,
         handleVisibleChange,
         handleSubmit,
+        handleCopy,
         addListFunc,
         registerSubtable,
         reload,