Ver Fonte

加工建单-建单成功复制加工单号2

zhaohuanhuan há 8 meses atrás
pai
commit
0529d78468
1 ficheiros alterados com 30 adições e 2 exclusões
  1. 30 2
      src/views/processing/register/index.vue

+ 30 - 2
src/views/processing/register/index.vue

@@ -114,25 +114,53 @@ const onConfirm = () => {
     scanError()
     return
   }
+
   showConfirmDialog({
-    title: '温馨提示', message:'是否确认建单',keyboardEnabled:false })
+    title: '温馨提示', message:'是否确认建单' })
     .then(() => {
     _createProcessing()
     }).catch(() => {})
 }
+
 const _createProcessing=()=>{
   const data={owner:ownerItem.value.id,ownerCode:ownerItem.value.code,note:note.value,warehouse,typeList:typeList.value,noList:toArray(code.value)}
   showLoading()
   createProcessing(data).then(res=>{
     closeLoading()
     scanSuccess()
-    showNotify({ type: 'success', duration: 3000, message: '建单成功' })
+    showConfirmDialog({
+      title: '建单成功',
+      message:`加工单号为:${res.data}`,
+      confirmButtonText:'复制'
+    })
+      .then(() => {
+        copyText(res.data)
+      })
+      .catch(() => {});
     reset()
   }).catch(err=>{
     scanError()
     closeLoading()
   })
 }
+const copyText=(txt) =>{
+  const textarea = document.createElement('textarea');
+  textarea.value =txt;
+  document.body.appendChild(textarea);
+  textarea.select();
+  try {
+    const successful = document.execCommand('copy');
+    if (successful) {
+      showNotify({ type: 'success', duration: 3000, message: '已复制' })
+    } else {
+      console.error('复制失败');
+    }
+  } catch (err) {
+    showNotify({ type: 'danger', duration: 3000, message: '复制失败' })
+  } finally {
+    document.body.removeChild(textarea);
+  }
+}
 const reset=()=>{
   code.value=""
   typeList.value=[]