Browse Source

no message

linwenxin 5 tháng trước cách đây
mục cha
commit
8053e4db76

+ 33 - 4
src/views/workOrder/workOrderPool/detailModule/workOrderInfo/buttons/copyInfo.vue

@@ -1,13 +1,16 @@
 <template>
-  <el-button v-if="btnys" :class="columnCopyClass" type="info" size="mini">{{ text }}</el-button>
-  <div v-else class="withinLine">
-    <el-button :class="columnCopyClass" type="primary" size="mini">{{ text }}</el-button>
+  <el-button v-if="btnys && columnCopyClassKey" :class="columnCopyClassKey" type="info" size="mini">{{
+    text
+  }}</el-button>
+  <div v-else-if="columnCopyClassKey" class="withinLine">
+    <el-button :class="columnCopyClassKey" type="primary" size="mini">{{ text }}</el-button>
   </div>
 </template>
 
 <script>
 import buttonMixin from './button_mixin.js'
 import ClipboardJS from 'clipboard'
+import md5 from 'md5'
 var nrBR = `
 `
 export default {
@@ -34,6 +37,11 @@ export default {
       default: false
     }
   },
+  data() {
+    return {
+      columnCopyClassKey: 'name-' + this.getRandom16Chars(md5(this.columnCopyClass + '_' + this.orderInfo.id))
+    }
+  },
   mounted() {
     this.textCopy()
   },
@@ -43,6 +51,27 @@ export default {
     }
   },
   methods: {
+    getRandom16Chars(str) {
+      // 确保输入字符串的长度是32
+      if (str.length !== 32) {
+        throw new Error('输入字符串必须是32个字符长')
+      }
+      // 创建一个存储选中的字符的数组
+      let selectedChars = []
+      // 使用 Set 来确保没有重复的索引
+      let indices = new Set()
+      // 随机选择16个不同的索引
+      while (indices.size < 10) {
+        let randomIndex = Math.floor(Math.random() * 32)
+        indices.add(randomIndex)
+      }
+      // 根据选中的索引提取字符
+      indices.forEach(index => {
+        selectedChars.push(str[index])
+      })
+      // 返回选中的16个字符组成的字符串
+      return selectedChars.join('')
+    },
     // 组装复制内容
     cpFormInfo() {
       if (this.cpText) {
@@ -68,7 +97,7 @@ export default {
         if (this.clipboard?.listener?.destroy) {
           this.clipboard.listener.destroy()
         }
-        this.clipboard = new ClipboardJS(`.${this.columnCopyClass}`, {
+        this.clipboard = new ClipboardJS(`.${this.columnCopyClassKey}`, {
           text: this.cpFormInfo
         })
         this.clipboard.on('success', () => {

+ 6 - 1
src/views/workOrder/workOrderPool/detailModule/workOrderInfo/index.vue

@@ -16,7 +16,12 @@
           :form-items="dispatchInfo"
         >
           <div slot="internal-bottom" style="text-align: right">
-            <copy-info text="复制工单信息" :info="dispatchInfo" :order-info="orderInfo" />
+            <copy-info
+              text="复制工单信息"
+              columnCopyClass="columnCopyClasslinonnoin"
+              :info="dispatchInfo"
+              :order-info="orderInfo"
+            />
           </div>
           <div slot="right" style="width: 55%; position: relative">
             <div class="pgxxTable">