Quellcode durchsuchen

refactor: 优化代码

yongCode vor 5 Monaten
Ursprung
Commit
abcc5be22b
3 geänderte Dateien mit 37 neuen und 33 gelöschten Zeilen
  1. 0 1
      src/App.vue
  2. 36 31
      src/views/DetailView.vue
  3. 1 1
      src/views/HomeView.vue

+ 0 - 1
src/App.vue

@@ -11,7 +11,6 @@ import { useWindowSize } from '@vant/use';
 const appStore = useAppStore()
 const { width } = useWindowSize();
 watch(width, (value) => {
-  console.log('window resized',value);
   const device = value < 768 ? 'phone' : 'pc';
   if (appStore.device === device) return
   appStore.setDevice(device)

+ 36 - 31
src/views/DetailView.vue

@@ -60,34 +60,37 @@
             >
               {{ breadTitle }}
             </div>
-            <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex">
-              <div>物料名称:</div>
-              <div class="font-['PingFang-SC'] text-sm font-normal">{{ selectMaterialName }}</div>
-            </div>
-            <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex">
-              <div class="min-w-20">物料规格:</div>
-              <div>
-                <van-tag
-                  v-for="i in wlList"
-                  :key="i.id"
-                  :color="i.id === wlSelectId ? '#004EA2' : '#F0F0F0'"
-                  :text-color="i.id === wlSelectId ? '#FFFFFF' : '#000000'"
-                  class="m-1 h-[35px] leading-[35px]"
-                  @click="changeWlCode(i)"
-                  >{{ i.specifications }}</van-tag
-                >
+            <template v-if="wlList.length > 0">
+              <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex">
+                <div>物料名称:</div>
+                <div class="font-['PingFang-SC'] text-sm font-normal">{{ selectMaterialName }}</div>
               </div>
-            </div>
-            <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex items-center">
-              <div>物料编码:</div>
-              <div>{{ selectWlCode }}</div>
-              <van-icon
-                v-show="selectWlCode"
-                name="description-o"
-                class="text-[#004EA2] description-o ml-1 cursor-pointer"
-                @click="codeCopy"
-              />
-            </div>
+              <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex">
+                <div class="min-w-20">物料规格:</div>
+                <div>
+                  <van-tag
+                    v-for="i in wlList"
+                    :key="i.id"
+                    :color="i.id === wlSelectId ? '#004EA2' : '#F0F0F0'"
+                    :text-color="i.id === wlSelectId ? '#FFFFFF' : '#000000'"
+                    class="m-1 h-[35px] leading-[35px] cursor-pointer"
+                    @click="changeWlCode(i)"
+                    >{{ i.specifications }}</van-tag
+                  >
+                </div>
+              </div>
+              <div class="font-['PingFang-SC'] text-sm font-normal mt-10 flex items-center">
+                <div>物料编码:</div>
+                <div>{{ selectWlCode }}</div>
+                <van-icon
+                  v-show="selectWlCode"
+                  name="description-o"
+                  class="text-[#004EA2] description-o ml-1 cursor-pointer"
+                  @click="codeCopy"
+                />
+              </div>
+            </template>
+
             <div class="font-['PingFang-SC'] text-sm font-normal mt-10">
               <div>附件:</div>
               <van-cell-group>
@@ -122,12 +125,12 @@ import { useRoute, useRouter } from 'vue-router'
 import { detailList } from '@/api/index.js'
 import Clipboard from 'clipboard'
 import { listTools } from '@/api/index.js'
+import { ElMessage } from 'element-plus'
 
 const router = useRouter()
 const route = useRoute()
 const queryId = ref(route.query.id)
 const queryToolName = ref(route.query.toolName)
-console.log('route.query.id', queryId.value)
 
 const wlList = ref([])
 const wlSelectId = ref(0)
@@ -142,9 +145,9 @@ const breadTitle = ref('')
 const typeOptions1Ref = ref([])
 const init = () => {
   detailList({ id: queryId.value }).then((res) => {
-    const toolDetails = res.data.toolDetails
+    const toolDetails = res.data.toolDetails || []
     wlList.value = toolDetails.filter((item) => item.informationType === 'wl')
-    console.log(wlList.value)
+    // console.log(wlList.value)
     if (wlList.value.length > 0) {
       selectWlCode.value = wlList.value[0].materialNo
       selectMaterialName.value = wlList.value[0].materialName
@@ -183,9 +186,11 @@ const codeCopy = async () => {
   // 添加成功事件处理函数
   clipboard.on('success', (e) => {
     e.clearSelection()
+    ElMessage.success('粘贴成功')
   })
   // 添加失败事件处理函数
   clipboard.on('error', () => {
+    ElMessage.error('无法复制到剪贴板!')
     console.warn('无法复制到剪贴板!')
   })
 }
@@ -198,7 +203,7 @@ const changeWlCode = ({ id, materialNo, materialName }) => {
 //  informationType 物料  wl  点击切换 物料编码 materialNo
 //  informationType 示意图 syt 左侧图
 const fileDownload = ({ fileName, filePath }) => {
-  console.log('filePath', filePath)
+  // console.log('filePath', filePath)
   const el = document.createElement('a')
   el.style.display = 'none'
   el.setAttribute('target', '_blank')

+ 1 - 1
src/views/HomeView.vue

@@ -282,7 +282,7 @@ const handleDetail = (row) => {
 }
 
 .tool-card {
-  @apply w-[165px] h-[270px] mx-auto mb-2 flex flex-col border box-content shadow-sm rounded-sm md:w-[220px] md:h-[330px];
+  @apply w-[165px] h-[270px] mx-auto mb-2 flex flex-col border box-content shadow-sm rounded-sm md:w-[220px] md:h-[330px] cursor-pointer;
 }
 .tool-card-none {
   @apply w-[165px] h-[270px] mx-auto mb-2 flex flex-col box-content rounded-sm md:w-[220px] md:h-[330px];